简体   繁体   中英

Mysql/php SELECT ORDER BY

I have a select like:

SELECT * FROM xxx WHERE id = 5 ORDER BY id DESC

But I need to order my select with the "Name" column that is into another Table... How can I do ?

SELECT  xxx.*, yyy.name
FROM    xxx
JOIN    yyy
ON      yyy.x_id = xxx.id
WHERE   xxx.id = 5
ORDER BY
        yyy.name DESC

我相信这是朝着正确的方向前进:

SELECT * from xxx LEFT JOIN yyy ON yyy.name = xxx.whateverkey WHERE id = 5 ORDER BY yyy.name DESC

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM