要想多表查询,是有条件的.一般是几张表结构相似或者是有一样的id号关联.例如:select*from表1,表2,表3这是把3张表结果全部查出来select*from表1wherenotexists(select0from表2where表1.id=表2.id)。
- 情感问答
- 答案列表
多表查询sql:多表联合查询sql语句[朗读]
select表1.*,表2.time1,表2.time2,表3.testfrom表1,表2,表3where表1.cd=表2.idand表1.cd=表3.idand(表1.timebetween('2008-4-1','yyyy-mm-dd')and('2008-4-30','yyyy-mm-dd'))。
既然是多表连接查询.那我假设a,b表都有一个共通的字段,叫id.那么sql就是这么写selecta.j,a.k,b.mfromaleftjoinbona.id=b.idwhere条件明白了吗?谢谢采纳。
selectt1fromawherea.t2in(selectu1fromb)anda.t3in(selectu1fromb)a.t4in(selectu1fromb)。
selecta.shopid,a.name,a.timeb.intentfrom表一a,表二bwherea.shopid=b.shopidorderbyb.intentdescselecta.shopid,a.name,a.timeb.intentfrom表一ainnerjoin表二bona.shopid=b.shopidorderbyb.intentdesc。