MYSQL 怎麼 LEFT JOIN 多表聯查

wqzbxh發表於2018-11-23

三表聯查:

SELECT a.count,b.bname,DATE_FORMAT(FROM_UNIXTIME(a.time),'%Y-%m-%d %H:%i:%s') as time,c.age
from  a LEFT JOIN b ON a.ruleid = b.id 
LEFT JOIN c ON a.topruleid = c.id
WHERE a.time BETWEEN 1542902400 AND 1542988799 AND a.sid = 624  

二表聯查:

SELECT a.count,b.bname,DATE_FORMAT(FROM_UNIXTIME(a.time),'%Y-%m-%d %H:%i:%s') as time
from  a LEFT JOIN b ON a.ruleid = b.id 
WHERE a.time BETWEEN 1542902400 AND 1542988799 AND a.sid = 624  

其他查詢,大致相似,自己可以借鑑研究一下

相關文章