多表查詢: 顯示內連接: select 欄位列表 from 表名1 inner join 表名1 on 條件 * inner 可忽略 select * from student inner join class on student.clas_id=class.id 隱式內連接: 使用where: ...
多表查詢:
顯示內連接:
select 欄位列表 from 表名1 inner join 表名1 on 條件
* inner 可忽略
select * from student inner join class on student.clas_id=class.id
隱式內連接:
使用where:
select t1.name,t2.name from student t1,class t2 where t1.class_id=t2.id
外連接:
左外鏈接
右外鏈接
*outer一般忽略
select * from student left join outer class on student.clas_id=class.id
子查詢:
select *from student where class_id = (select max(class_id) from student)
select *from student where class_id in (select id from student where id=2 or id =3)
select *from student t1 ,(select *from class where class.id>2) where t1.class_id=t2.id