力扣 高频 SQL 50 题(基础版)题解

查询(单关系查询)

1757. 可回收且低脂的产品

知识点:SELECT,FROM,WHERE

SELECT product_id
FROM Products 
WHERE low_fats = 'Y' AND recyclable = 'Y';

584. 寻找用户推荐人

知识点:SELECT,FROM,WHERE

SELECT name
FROM customer
WHERE referee_id != 2 OR referee_id IS NULL;

595. 大的国家

知识点:SELECT,FROM,WHERE

SELECT name,population,area
FROM World
WHERE area>=3000000 OR population>=25000000;

2356. 每位教师所教授的科目种类的数量

知识点:SELECT,FROM,WHERE,文本处理函数

SELECT tweet_id
FROM Tweets
WHERE LENGTH(content)>15;

连接

1068. 产品销售分析 I

知识点:内连接

SELECT unique_id,name
FROM Employees 
LEFT OUTER JOIN EmployeeUNI
ON EmployeeUNI.id=Employees.id;

1378. 使用唯一标识码替换员工ID

知识点:外连接

SELECT unique_id,name
FROM Employees 
LEFT OUTER JOIN EmployeeUNI
ON EmployeeUNI.id=Employees.id;

577. 员工奖金

知识点:外连接,where

SELECT name,bonus
FROM Employee
LEFT OUTER JOIN Bonus
ON Employee.empId = Bonus.empId
WHERE bonus < 1000 OR bonus IS NULL;

你可能感兴趣的:(sql,数据库)