Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have an issue I really don't understand. In fact, I have a database of movies where there's a table for actors,containing two colums (movie id and name).

For example, then I enter the movie id of Django Unchained, the first result is Jamie Fox (the main actor). But then I enter, this sql query (i would expect to get Jamie Fox, Christoph and Leonardo):

SELECT * FROM LesActeurs WHERE film_id=68718 ORDER BY acteur LIMIT 3

But I get 3 actors by alphabetical order. Do You Know how could I mimic the DB Browser order with command (I'm a beginner)?

Thank you!

result DB Browser

result SQL


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
378 views
Welcome To Ask or Share your Answers For Others

1 Answer

Without any other column to order by, you can't get that result, at least not reliably. Without an explicit order by clause, the database is free to return the rows in whatever order it chooses (often it's just the order in which they were inserted).

If you want to get reliably get Jamie, Christophe and Leonardo you could add another column (e.g., "importance"), populate it and then query and explicitly order by it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...