LeetCode 620. funny movie (MySQL)

The title
of a city opened a new cinema, attract a lot of people came to see the movie. The cinema special attention to the user experience, there is a dedicated LED display board to do a movie recommendation, it announced the critics and movie-related described above.

As the director of the movie theater information, you need to write a SQL query to find all the videos described as non-boring (not boring) and id is an odd movie, please arrange results by grade rating.

例如,下表 cinema:
±--------±----------±-------------±----------+
| id | movie | description | rating |
±--------±----------±-------------±----------+
| 1 | War | great 3D | 8.9 |
| 2 | Science | fiction | 8.5 |
| 3 | irish | boring | 6.2 |
| 4 | Ice song | Fantacy | 8.6 |
| 5 | House card| Interesting| 9.1 |
±--------±----------±-------------±----------+

For the above example, the correct output is:
± -------- ---------- ± ± ± --- ------------- + -------
| ID | Movie | Description | Rating |
± -------- ± ± ---------- ------------ - ± ---------- +
|. 5 | House Card | Interesting | 9.1 |
|. 1 | War | Great 3D | 8.9 |
± -------- ± ------- --- ± ------------- ± ---------- +
source: stay button (LeetCode)
link: https: //leetcode-cn.com/problems/ not-boring-movies

Problem-solving ideas:
1, described as non-boring (not boring) Description = "Boring;!
2, id is an odd number, i.e. 2 modulo equal to id 1, id% 2 = 1;
. 3, results Please sorted by rating Rating, the results are sorted in reverse order by rating, OREDR bY rating DESC.

SELECT *
FROM cinema
WHERE description!="boring" AND id%2=1
ORDER BY rating DESC;
Released eight original articles · won praise 0 · Views 105

Guess you like

Origin blog.csdn.net/weixin_43346653/article/details/104344050