-- 查詢至少有一門課與學號為"01"的同學所學相同的同學的信息
** group_concat函數將學生所學課程轉化為字符串,比較字符串
select * from student where s_id in( select distinct b.s_id from score b where b.c_id in ( select c_id from score where s_id = '01'))
-- 查詢和"01"號的同學學習的課程完全相同的其他同學的信息
select * from student where s_id in ( select s_id from score t1 group by s_id having group_concat(c_id) = ( select group_concat(c_id) as str2 from score where s_id = '01') and s_id != '01');
** A是B的子集,且AB元素個數相同,則AB相等
select a.* from student a where a.s_id in( select distinct s_id from score where s_id != '01' and c_id in( select c_id from score where s_id = '01') group by s_id having count(1)=( select count(1) from score where s_id = '01'));
--2019/04/22 and 04/23