PHP MySQL Query Create Tables
From w3cyberlearnings
Contents |
PHP MySQL Create Table and Insert Sample Records
Create these two tables and insert some sample records for this tutorial.
Create employee table
CREATE TABLE IF NOT EXISTS employee( id INT NOT NULL AUTO_INCREMENT, name VARCHAR(200) NOT NULL, grade char(1) NOT NULL, PRIMARY KEY(id) ); INSERT INTO employee(name,grade) VALUES('John','a'); INSERT INTO employee(name,grade) VALUES('Mark','a'); INSERT INTO employee(name,grade) VALUES('Smit','a'); INSERT INTO employee(name,grade) VALUES('Lili','a'); INSERT INTO employee(name,grade) VALUES('Alex','c'); INSERT INTO employee(name,grade) VALUES('Walton','c'); INSERT INTO employee(name,grade) VALUES('Kim','d'); INSERT INTO employee(name,grade) VALUES('Marry','d'); INSERT INTO employee(name,grade) VALUES('Paul','c'); INSERT INTO employee(name,grade) VALUES('Christ','c');
Create employee_salary table
CREATE TABLE employee_salary( id INT NOT NULL AUTO_INCREMENT, employee_id INT NOT NULL, salary DOUBLE NOT NULL, PRIMARY KEY(id) ); INSERT INTO employee_salary(employee_id,salary) VALUES(1,25); INSERT INTO employee_salary(employee_id,salary) VALUES(2,20); INSERT INTO employee_salary(employee_id,salary) VALUES(3,23); INSERT INTO employee_salary(employee_id,salary) VALUES(4,25); INSERT INTO employee_salary(employee_id,salary) VALUES(5,30); INSERT INTO employee_salary(employee_id,salary) VALUES(6,35); INSERT INTO employee_salary(employee_id,salary) VALUES(7,40); INSERT INTO employee_salary(employee_id,salary) VALUES(8,80); INSERT INTO employee_salary(employee_id,salary) VALUES(9,50); INSERT INTO employee_salary(employee_id,salary) VALUES(10,60);
Related Links
- Create Two Tables for this section tutorial
- Query Uses AND Operator
- Query Uses OR Operator
- Query Uses INNER JOIN
- Query Uses LEFT OUTER JOIN
- Query Uses RIGHT OUTER JOIN
- Query with Subquery