MySQL左联多表查询where条件写法示例
来源:动视网
责编:小采
时间:2020-11-09 21:01:21
MySQL左联多表查询where条件写法示例
MySQL左联多表查询where条件写法示例: 代码如下: select * from _test a left join _test b on a.id=b.id where a.level='20' and a.month='04' and b.level='20' and b.month='03'; select a.*,b.* from (select * from _test where
导读MySQL左联多表查询where条件写法示例: 代码如下: select * from _test a left join _test b on a.id=b.id where a.level='20' and a.month='04' and b.level='20' and b.month='03'; select a.*,b.* from (select * from _test where
代码如下:
select * from _test a left join _test b on a.id=b.id where a.level='20' and a.month='04' and b.level='20' and b.month='03';
select a.*,b.* from (select * from _test where level='20' and month='04') as a left join (select * from _test where level='20' and month='03') as b on a.id=b.id;
这两条语句结果是不同的,应该是left join的时候如果条件是多个表mysql会自动转成内联导致,第二条语句才能达到正确的目的(为了找到相差的两条数据)。


您可能感兴趣的文章:
解析Mysql多表查询的实现MySQL 多表查询实现分析详解MySQL数据库--多表查询--内连接,外连接,子查询,相关子查询
MySQL左联多表查询where条件写法示例
MySQL左联多表查询where条件写法示例: 代码如下: select * from _test a left join _test b on a.id=b.id where a.level='20' and a.month='04' and b.level='20' and b.month='03'; select a.*,b.* from (select * from _test where