Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Join (SQL)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Example tables== To explain join types, the rest of this article uses the following tables: {| class="wikitable" style="text-align:center; float:left; margin-right:5px" |+Employee table |- ! LastName !! DepartmentID |- | Rafferty ||31 |- | Jones || 33 |- | Heisenberg || 33 |- | Robinson || 34 |- | Smith|| 34 |- | Williams || {{null result}} |} {| class="wikitable" style="text-align:center; float:left; margin-left:5px" |+Department table |- ! DepartmentID !! DepartmentName |- | 31 || Sales |- | 33 || Engineering |- | 34 || Clerical |- | 35 || Marketing |} {{clear}} <code>Department.DepartmentID</code> is the [[primary key]] of the <code>Department</code> table, whereas <code>Employee.DepartmentID</code> is a [[foreign key]]. Note that in <code>Employee</code>, "Williams" has not yet been assigned to a department. Also, no employees have been assigned to the "Marketing" department. These are the SQL statements to create the above tables: <syntaxhighlight lang="sql" line="1"> CREATE TABLE department( DepartmentID INT PRIMARY KEY NOT NULL, DepartmentName VARCHAR(20) ); CREATE TABLE employee ( LastName VARCHAR(20), DepartmentID INT REFERENCES department(DepartmentID) ); INSERT INTO department VALUES (31, 'Sales'), (33, 'Engineering'), (34, 'Clerical'), (35, 'Marketing'); INSERT INTO employee VALUES ('Rafferty', 31), ('Jones', 33), ('Heisenberg', 33), ('Robinson', 34), ('Smith', 34), ('Williams', NULL); </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)