发布网友 发布时间:2022-05-07 16:21
共4个回答
懂视网 时间:2022-05-07 20:42
bitsCN.commysql三表关联分组带where
mysql
查不出来:
SELECT e.id,e.ename,COUNT(s.id) AS total FROM enterprise e LEFT JOIN comm_port p ON e.id = p.eid LEFT JOIN sendedoutbox s ON p.port = s.CommPort WHERE s.SendTime BETWEEN '2013-08-09 15:31:35' AND '2013-08-28 10:47:28' GROUP BY p.eid ORDER BY total DESC
正确能查出来:
SELECT e.id,e.ename,COUNT(s.id) AS total FROM enterprise e LEFT JOIN comm_port p ON e.id = p.eid LEFT JOIN (SELECT * FROM sendedoutbox s WHERE s.SendTime BETWEEN '2013-08-09 15:31:35' AND '2013-08-28 10:47:28') s ON p.port = s.CommPort GROUP BY p.eid ORDER BY total DESC
bitsCN.com
热心网友 时间:2022-05-07 17:50
ZHFLVG|五级
热心网友 时间:2022-05-07 19:08
select * from table1 a,table2 b,table3 c where a.1ID = b.1ID inner join a.1ID = C.2ID;追问PK FK用设置吗?怎么设置捏?追答应该这样就行了
热心网友 时间:2022-05-07 20:43
select * from table1 a,table2 b,table3 c