SQL Insert

SQL Insert Example One - A Basic Insert

Q: How would we add John Travolta as being in Pulp Fiction to the Thespian_Film_Table table?
 Insert Into Thespian_Film_Table (Thespian_Last_Name, 
                         Values ("Travolta", 
                                 "Pulp Fiction");
Note: The first parenthesis contains the column names in the Thespian_Film_Table. The second parenthesis contain the data to go into the row being inserted. The data being inserted in the second line must be in order corresponding to the column name order in the first line.

SQL Insert Example Two - Inserting Rows From One Table Into Another Table

Q: I have created my own John_Travolta_Film_Table. How can I bring all the rows for John Travolta in the Thespian_Film_Table into my new table?
 Insert Into John_Travolta_Film_Table (Thespian_Last_Name,
 Select Thespian_Last_Name, 
   From Thespian_Film_Table
  Where Thespian_Last_Name = "Travolta"
    and Thespian_First_Name = "John";
Note: Just as in example number one, the column names being inserted into must be in the same order as the column names being selected from.
Special Thanks: to Tomislav for catching a dyslexic typo on this page.
Sign in to be the first to comment on SQL Insert.