1.join多表连接查询
inner join:只显示连接条件不为空的数据,如果on后面的连接数据为空 则查询不到。
select a.name, b.name from aaa as a inner join bbb as b on a.id = b.id where a.age = 18 and b.add = 'qwe'
left join:以表aaa为主表,会把连接之后aaa表中的数据全部显示出来,即便bbb表中的没有与之对应的id 也会查询出来。
select a.name, b.name from aaa as a left join bbb as b on a.id = b.id where a.age = 18 and b.add = 'qwe'
right join:以表bbb为主表,会把连接之后bbb表中的数据全部显示出来,即便aaa表中的没有与之对应的id 也会查询出来。
select a.name, b.name from aaa as a right join bbb as b on a.id = b.id where a.age = 18 and b.add = 'qwe'
标签:知识点,常用,join,name,表中,bbb,SQL,aaa,id From: https://www.cnblogs.com/wangdianchao/p/17835050.html