当前位置: 代码迷 >> PHP >> 排序 让一个表中的数据依照另一个表排序
  详细解决方案

排序 让一个表中的数据依照另一个表排序

热度:378   发布时间:2016-04-28 17:40:07.0
排序 让一个表中的数据按照另一个表排序
比如表A有字段
id ,name
2   test
表B有字段  A表中的id等于B表中的 location_id

id  uid  location_id num  
1    1     2                  5
2   3      2                 6    
3   4      3                1

如何写sql语句让表A中的数据 按照表B中 num 排序 而且是总计的num 排序

------解决思路----------------------
select A.id,A.name from B inner join A on B.location_id = A.id order by B.num desc
  相关解决方案