MySQL Simple INSERT INTO Example

Now we have created a database, connected to it and then created some tables that have primary and foreign keys, all we need to do now is add some data...

SELECT and INSERT INTO are both DML ( Data Manipulation Language )

/* POPULATE THE CUSTOMERS TABLE*/


INSERT INTO Customers (FirstName,LastName) VALUES ("Mark","James");
INSERT INTO Customers (FirstName,LastName) VALUES ("Steve","James");
INSERT INTO Customers (FirstName,LastName) VALUES ("Paul","James");
INSERT INTO Customers (FirstName,LastName) VALUES ("Clair","James");
INSERT INTO Customers (FirstName,LastName) VALUES ("Will","James");

/* POPULATE THE PRODUCTS TABLE*/
INSERT INTO Products (Title) VALUES ("Shoes");
INSERT INTO Products (Title) VALUES ("Jackets");
INSERT INTO Products (Title) VALUES ("Shampoo");
INSERT INTO Products (Title) VALUES ("Soap");
INSERT INTO Products (Title) VALUES ("Windows");

/* POPULATE THE ORDERS TABLE*/
INSERT INTO Orders (OCustID,OProdID) VALUES (1,1);
INSERT INTO Orders (OCustID,OProdID) VALUES (1,2);
INSERT INTO Orders (OCustID,OProdID) VALUES (1,3);
INSERT INTO Orders (OCustID,OProdID) VALUES (2,4);
INSERT INTO Orders (OCustID,OProdID) VALUES (3,5);
INSERT INTO Orders (OCustID,OProdID) VALUES (4,1);

No comments:

Post a Comment