MySQL左联多表查询where条件写法示例
更新时间:2015年02月13日 09:05:39 投稿:junjie
这篇文章主要介绍了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 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会自动转成内联导致,第二条语句才能达到正确的目的(为了找到相差的两条数据)。


相关文章
解决ERROR 1129 (HY000): Host ‘xxx‘ is blocked because
这篇文章主要介绍了解决ERROR 1129 (HY000): Host ‘xxx‘ is blocked because of many问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教2024-04-04


最新评论