For example, table 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 example above, the output should be:
+---------+-----------+--------------+-----------+ | id | movie | description | rating | +---------+-----------+--------------+-----------+ | 5 | House card| Interesting| 9.1 | | 1 | War | great 3D | 8.9 | +---------+-----------+--------------+-----------+
MOD()
function [Accepted]Algorithm
\nWe can use the mod(id,2)=1
to determine the odd id, and then add a description != \'boring\'
should address this problem.
MySQL
\nselect *\nfrom cinema\nwhere mod(id, 2) = 1 and description != \'boring\'\norder by rating DESC\n;\n