1、多表查询
内连接:select * from aa inner join cc on aa.id=cc.s-id
左连接:select * from aa left join cc on aa.id=cc.s-id
右连接:select * from aa right join cc on aa.id=cc.s-id
基本连接:select * from aa,cc where aa.id=cc.s-id
硬连接:select * from aa union select * from cc
2、查询张三的成绩:
临时表法:select score from ( )t where t.name='zhangsan'
( )中可以填: select * from aa inter/left/right join on aa.id=cc.s-id
select * from aa,cc where aa.id=cc.s-id
嵌套法:
select score from cc where s-id=(select id from aa where name='zhangsan' )
or
select score from cc where s-id in(select id from aa where name='zhangsan' )
基本连接:select score from aa,cc where aa.id=cc.s-id and name='zhangsan'
|
|