Ai
1 Star 0 Fork 0

逸扬/leetcode-hub-mysql

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
lc-1623.test 1.33 KB
一键复制 编辑 原始数据 按行查看 历史
# $1623. 三人国家代表队
# https://leetcode.cn/problems/all-valid-triplets-that-can-represent-a-country/
# SQL架构
Create table If Not Exists SchoolA (student_id int, student_name varchar(20));
Create table If Not Exists SchoolB (student_id int, student_name varchar(20));
Create table If Not Exists SchoolC (student_id int, student_name varchar(20));
Truncate table SchoolA;
insert into SchoolA (student_id, student_name) values ('1', 'Alice');
insert into SchoolA (student_id, student_name) values ('2', 'Bob');
Truncate table SchoolB;
insert into SchoolB (student_id, student_name) values ('3', 'Tom');
Truncate table SchoolC;
insert into SchoolC (student_id, student_name) values ('3', 'Tom');
insert into SchoolC (student_id, student_name) values ('2', 'Jerry');
insert into SchoolC (student_id, student_name) values ('10', 'Alice');
# Write your MySQL query statement below
select
sa.student_name as member_A,
sb.student_name as member_B,
sc.student_name as member_C
from
SchoolA sa,
SchoolB sb,
SchoolC sc
where
sa.student_id != sb.student_id
and sb.student_id != sc.student_id
and sa.student_id != sc.student_id
and sa.student_name != sb.student_name
and sb.student_name != sc.student_name
and sa.student_name != sc.student_name;
# clean-up
drop table SchoolA;
drop table SchoolB;
drop table SchoolC;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gdut_yy/leetcode-hub-mysql.git
git@gitee.com:gdut_yy/leetcode-hub-mysql.git
gdut_yy
leetcode-hub-mysql
leetcode-hub-mysql
master

搜索帮助