开发者

Mysql/php SELECT ORDER BY

开发者 https://www.devze.com 2023-02-19 06:44 出处:网络
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开发者_C百科 another Table...

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开发者_C百科 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


I believe this is heading in the right direction:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消