SQL查询语句多表连接笔记记录

SQL查询语句多表连接笔记记录

SQL查询语句多表连接笔记记录 

SQL查询语句多表连接笔记记录 

 

#左外联结
SELECT *
from vendors
left join products
on vendors.ID=products.VID ;

# 右外链接

SELECT *
from vendors
RIGHT join products
on vendors.ID=products.VID ;

#同上
SELECT *
from products
left join vendors
on vendors.ID=products.VID ;


#内连接 join  inner join 


SELECT *
from vendors
join products
on vendors.ID=products.VID ;

SELECT *
from vendors
inner join products
on vendors.ID=products.VID ;

#三表连接  

SELECT *
from vendors
left join products
on vendors.ID=products.VID
left join testtable
on products.ID=testtable.testID

SELECT *
from vendors
left join products
on vendors.ID=products.VID
left join testtable
on products.ID=testtable.testID
where vendors.name='供应商A'


select * from vendors left join products on vendors.ID=products.VID
 

上一篇:java制作简单的坦克大战


下一篇:rtmp协议学习笔记