欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

620. 有趣的电影(MySQL)(多条件查询+排序(没法union))

程序员文章站 2024-03-08 15:58:46
...

1 题目

620. 有趣的电影(MySQL)(多条件查询+排序(没法union))

2 MySQL

2.1 方法一(不等于,取模,排序)

select id, movie, description, rating
from cinema
where description <> 'boring'
    and id % 2 = 1
order by rating desc;

写的不好
1 != 改用 <>
2 取模方法:& mod % (判断奇偶数才能用&;效率未知)
3 and 前应该放筛选快的条件

select id, movie, description, rating
from cinema
# where id % 2 = 1
# where mod(id, 2) = 1
where id & 1 = 1
    and description <> 'boring'
order by rating desc;
相关标签: MySQL