LEFT JOIN 多表选择数据(任意join)

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/u013372487/article/details/71104339

这里写图片描述

如上图所示,a表为上线表,b,c分别为数据总集表,从上线表中查找有效数据(即在a或b表中数据正常)

从a中获取存在表b或表c中有效数据

获取第一页有效数据,sql语句:

select `a`.aas,`a`.aasValue,`a`.sort,`b`.subhead `subName`, CONCAT_WS('',`b`.name,`c`.name) as name,
CONCAT_WS('',`b`.wktype ,`c`.wktype ) as vwktype,
CONCAT_WS('',`b`.cover,`c`.cover) as cover, `b`.corner 
from A AS a left join B AS b on a.aasValue=b.wkid and b.black=0 left join C AS c on a.aasValue=c.wkid and c.black=0 where a.type_id=1 AND a.status='1' AND (b.name != '' or c.name != '') order by a.sort desc limit 30 offset 0
展开阅读全文

没有更多推荐了,返回首页