有关按特定顺序创建列表的SQL查询

时间:2017-10-26 16:50:32

标签: mysql sql

我有2张桌子,我需要按照降序排列某个类型列表。

Documentary(Title, Duration, language, Genre)

Rating(LoginNames, Rating)

我想按照评级的降序为某个类型创建一个列表。

我想出了这个:

SELECT * FROM Genre, Rating 
ORDER BY rank DESC

我不确定我是否会得到结果的正确结果。谢谢!

1 个答案:

答案 0 :(得分:1)

评论更新:

SELECT
    DocumentaryTbl.Title,
    DocumentaryTbl.Genre,
    RatingTbl.Rating,
    ... -- I would avoid *, choose the columns you'd like
FROM
   Documentary AS DocumentaryTbl
LEFT JOIN
   Rating AS RatingTbl
   ON DocumentaryTbl.DocumentaryID = RatingTbl.DocumentaryID
ORDER BY
   RatingTbl.Rating DESC; -- Or whichever column(s) you want to sort by