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
精彩评论