你也可以 create view xx as SELECT aid,a1,a3,B.*,C.* FROM A LEFT JOIN B ON aid=b_aid INNER JOIN C ON aid=c_aid
先给要搜索的加索引,a1=2017.3.20,c1=2017.3.20,b4=6,c4=7
这4个可以先查再比对在关联
select a1,a2,a3,a4,b1,b2,b3,b4,c1,c2,c3,c4
from
(select a1,a2,a3,a4 from aa where aa.a1=2017.3.20) aa,
(select b1,b2,b3,b4 from bb where bb.b4=6) bb,
(select c1,c2,c3,c4 from cc where cc.c1=2017.3.20 and cc.c4=7) cc,
where aa.a1=bb.b2,aa.a1=cc.c2
你这个不能这样查询,利用中间表(bookinfo)关联其它两表bookid booknotesselect bookinfo.isbn,booknotes.tiaoma,bookinfo.title,bookinfo.price,booknotes.bdate.booknotes.rdate from bookinfo left join bookid on bookinfo.isbn=bookid.isbn left join booknotes on bookinfo.id=booknotes.id
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)