Material del curso de SQL de la UNACAR 2020
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

26 行
382 B

  1. CREATE TABLE tabla1 (
  2. id INT PRIMARY KEY
  3. );
  4. CREATE TABLE tabla2 (
  5. id INT PRIMARY KEY
  6. );
  7. INSERT INTO tabla1(id) VALUES(1),(2),(3);
  8. INSERT INTO tabla2(id) VALUES(2),(3),(4);
  9. #union
  10. select id from tabla1
  11. union
  12. select id from tabla2
  13. #intersec
  14. select id from tabla1
  15. where id in (select id from tabla2)
  16. #except
  17. select id from tabla1
  18. where id not in (select id from tabla2)