Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. SQL> create table widgets (product_id int, color CHAR(25));
  2.  
  3. Table created.
  4.  
  5. SQL> insert into widgets values (1, 'red');
  6.  
  7. 1 row created.
  8.  
  9. SQL> insert into widgets values (2, 'blue');
  10.  
  11. 1 row created.
  12.  
  13. SQL> create table sprockets (product_id int, color CHAR(25));
  14.  
  15. Table created.
  16.  
  17. SQL> insert into sprockets values (1, 'green');
  18.  
  19. 1 row created.
  20.  
  21. SQL> insert into sprockets values (3, 'yellow');
  22.  
  23. 1 row created.
  24.  
  25. SQL> select * from widgets w left join sprockets s on s.product_id = w.product_id;
  26.  
  27. PRODUCT_ID COLOR PRODUCT_ID COLOR
  28. ---------- ------------------------- ---------- -------------------------
  29. 1 red 1 green
  30. 2 blue
  31.  
  32. SQL> select * from widgets w left join sprockets s on w.product_id = s.product_id;
  33.  
  34. PRODUCT_ID COLOR PRODUCT_ID COLOR
  35. ---------- ------------------------- ---------- -------------------------
  36. 1 red 1 green
  37. 2 blue
  38.  
  39. SQL> select * from sprockets s left join widgets w on s.product_id = w.product_id;
  40.  
  41. PRODUCT_ID COLOR PRODUCT_ID COLOR
  42. ---------- ------------------------- ---------- -------------------------
  43. 1 green 1 red
  44. 3 yellow
  45.  
  46. SQL> select * from sprockets s left join widgets w on w.product_id = s.product_id;
  47.  
  48. PRODUCT_ID COLOR PRODUCT_ID COLOR
  49. ---------- ------------------------- ---------- -------------------------
  50. 1 green 1 red
  51. 3 yellow
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement