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

WBOY
Release: 2016-06-23 13:37:26
Original
1236 people have browsed it

比如表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

谢谢你的热心回答

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template