SHARE
TWEET

Untitled

a guest Apr 24th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  
  3. CREATE DATABASE New_Database;
  4.  
  5. /* Creating Tables */
  6.  
  7. CREATE TABLE Employee(
  8. EmployeeID int,
  9. EmployeeFirstName varchar(20),
  10. EmployeeLastName varchar(20),
  11. PRIMARY KEY (EmployeeID)
  12. );
  13.  
  14. INSERT INTO Employee
  15.        VALUES  (155, 'Dianne', 'Lux'),
  16.                (283, 'Matt', 'Loe'),
  17.                (152, 'Anthony', 'Lee'),
  18.                (362, 'Lindsay', 'Moen'),
  19.                (421, 'Mable', 'Fan');
  20.  
  21.  
  22. Select * from Employee
  23.  
  24. CREATE TABLE Tool(
  25. ToolID int,
  26. Date_of_Last_Inspection varchar(100),
  27. Status_of_tool varchar(20) ,
  28. Tool_Name varchar(20),
  29. PRIMARY KEY (ToolID)
  30. );
  31.  
  32.  
  33. INSERT INTO Tool
  34.        VALUES  (155, '2017-07-18','Checked_out', 'Plunger'),
  35.                (283, '2019-02-13', 'in_storage', 'Screwdriver'),
  36.                (152, '2018-06-12', 'Checked_out', 'Nail_Gun'),
  37.                (362, '2017-01-03', 'in_storage', 'Pliers');
  38.  
  39. SELECT * FROM Tool
  40.  
  41. --- INNER JOIN
  42. select * from Tool T
  43. INNER JOIN Employee E
  44. ON t.EmployeeID =e.EmployeeID;
  45.  
  46. --- FULL JOINS
  47. select * from Tool t
  48. FULL JOIN Employee E
  49. ON t.EmployeeID = e.EmployeeID;
  50.  
  51. --- left outer join
  52. select * from Tool t
  53. LEFT OUTER JOIN Employee E
  54. ON e.EmployeeID=t.EmployeeID;
  55.  
  56. ---Right outer join
  57. select * from Tool t
  58. RIGHT OUTER JOIN Employee E
  59. ON e.EmployeeID=t.EmployeeID;
  60.  
  61. --- Intersect
  62. Select * from Tool
  63. Intersect
  64. Select * Employee
  65.  
  66. ---Union
  67. Select * from Tool
  68. Union
  69. Select * from Employee
  70.  
  71. --- Except
  72. Select * from Tool
  73. Except
  74. Select * from Employee
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top