代码拉取完成,页面将自动刷新
# $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;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。