源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

MySQL左联多表查询where条件写法示例

  • 时间:2022-04-29 16:45 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:MySQL左联多表查询where条件写法示例
[u]复制代码[/u] 代码如下:
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会自动转成内联导致,第二条语句才能达到正确的目的(为了找到相差的两条数据)。 [img]http://files.jb51.net/file_images/article/201502/201521390340600.jpg?20151139358[/img] [img]http://files.jb51.net/file_images/article/201502/201521390415332.jpg?20151139424[/img]
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部