![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
SQL
梦康
菜鸟on the way
展开
-
查询所有订单的最新信息的SQL语句的写法 DISTINCT配合count和group by一起完成
场景:每个订单会持续更新,客户需要能查看每次更新的内容,所以每次更新我都会存一次,而不是在原来的基础上更新。 现在需要查看每个订单的最新信息。 SELECT *,count(DISTINCT ordernum) FROM xxxx group by ordernum order by addtime desc Array ( [0] => Array原创 2013-05-09 17:35:23 · 2114 阅读 · 0 评论 -
三表关联查询-多次LEFT JOIN...ON
$sql = "SELECT a.year,a.guid,a.description,b.description AS pic_des,c.year AS pic_year,c.month AS pic_month,c.day AS pic_day,c.file AS pic_file FROM m_honor2_honor2 a LEFT JOIN m_honor2_pics b ON a.g原创 2013-05-27 11:02:46 · 4143 阅读 · 0 评论