数据库
首页 > 数据库> > 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
 

标签:语句,多表,VID,vendors,products,SQL,join,ID,SELECT
来源: https://blog.csdn.net/lu_xiaochun/article/details/122827271