sql-查询

1757. 可回收且低脂的产品 - 力扣(LeetCode)

select product_id 
from Products 
where low_fats = 'Y' and  recyclable = 'Y'

下面是一种较为复杂的做法,不推荐

# Write your MySQL query statement below
select product_id
FROM Products 
WHERE (
    (CASE WHEN low_fats = 'Y' THEN 1 ELSE 0 END) = 1 
    AND 
    (CASE WHEN recyclable = 'Y' THEN 1 ELSE 0 END) = 1 
)

 584. 寻找用户推荐人 - 力扣(LeetCode)

select name 
from Customer 
where referee_id not in (2) or referee_id is null

or

select name 
from Customer 
where referee_id != 2 or referee_id is null

  

595. 大的国家 - 力扣(LeetCode)

 

select name,
    population,
    area
from World 
where population >= 25000000 or area >= 3000000 

 

1148. 文章浏览 I - 力扣(LeetCode)

distinct 去除重复的数值

select distinct author_id as id   
from Views 
where author_id = viewer_id
order by id 

1683. 无效的推文 - 力扣(LeetCode)

 

select tweet_id 
from Tweets 
where length(content) > 15

 

posted @ 2025-07-12 13:15  arroa  阅读(6)  评论(0)    收藏  举报