三表联查语句
$sql = “select a.,b.,c* from (tableA a LEFT JOIN table b ON a.字段=b.字段) LEFT JOIN tableC c ON c.字段=b.字段或者a.字段 where 条件”;
SQL按时间段group by
按小时分组
SELECT COUNT(*),FROM_UNIXTIME(dt) FROM sub_date GROUP BY FROM_UNIXTIME(dt, ‘%Y-%m-%d %H’)
按分钟分组
SELECT COUNT(*),FROM_UNIXTIME(dt) FROM sub_date GROUP BY FROM_UNIXTIME(dt, ‘%Y-%m-%d %H:%i’)
按天分组
SELECT COUNT(*),FROM_UNIXTIME(dt) FROM sub_date GROUP BY FROM_UNIXTIME(dt, ‘%Y-%m-%d’)
三表联删语句
DELECT t1,t2,t3 FROM t1,t2,t3 WHERE t1.id=t2.id and t1.id=t3.id and t2.id=t3.id and 条件