开发者

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开发者_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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜