How to Implement the combined query view in the mysql tutorial
Mysql>
Mysql> create table employee (
-> Id int,
-> First_name varchar (15 ),
-> Last_name varchar (15 ),
-> Start_date date,
-> End_date date,
-> Salary float (8, 2 ),
-> City varchar (10 ),
-> Description varchar (15)
-> );
Query OK, 0 rows affected (0.02 sec)
Mysql>
Mysql> create table job (
-> Id int,
-> Title varchar (20)
-> );
Query OK, 0 rows affected (0.06 sec)
Mysql>
Mysql> insert into employee (id, first_name, last_name, start_date, end_date, salary, city, description)
-> Values (1, 'jason ', 'martin', '000000', '000000', 19960725, 'toronto ', 'programmer ');
Query OK, 1 row affected (0.00 sec)
Mysql>
Mysql> insert into employee (id, first_name, last_name, start_date, end_date, salary, city, description)
-> Values (2, 'alison ', 'mathews', '000000', '000000', 19760321, 'vancouver ', 'tester ');
Query OK, 1 row affected (0.00 sec)
Mysql>
Mysql> insert into employee (id, first_name, last_name, start_date, end_date, salary, city, description)
-> Values (3, 'James ', 'Smith', '000000', '000000', 19781212, 'vancouver ', 'tester ');
Query OK, 1 row affected (0.00 sec)
Mysql>
Mysql> insert into employee (id, first_name, last_name, start_date, end_date, salary, city, description)
-> Values (4, 'cela', 'Rice ', '000000', '000000', 19821024, 'vancouver', 'manager ');
Query OK, 1 row affected (0.00 sec)
Mysql>
Mysql> insert into employee (id, first_name, last_name, start_date, end_date, salary, city, description)
-> Values (5, 'Robert ', 'black', '000000', '000000', 19840115, 'vancouver', 'tester ');
Query OK, 1 row affected (0.01 sec)
Mysql>
Mysql> insert into employee (id, first_name, last_name, start_date, end_date, salary, city, description)
-> Values (6, 'linda ', 'green', '000000', '000000', 19870730, 'New york', 'tester ');
Query OK, 1 row affected (0.00 sec)
Mysql>
Mysql> insert into employee (id, first_name, last_name, start_date, end_date, salary, city, description)
-> Values (7, 'David ', 'Larry', '123', '123', 19901231, 'New york ', 'manager ');
Query OK, 1 row affected (0.00 sec)
Mysql>
Mysql> insert into employee (id, first_name, last_name, start_date, end_date, salary, city, description)
-> Values (8, 'James ', 'cat', '000000', '000000', 19960917, 'vancouver', 'tester ');
Query OK, 1 row affected (0.00 sec)
Mysql>
Mysql> insert into job (id, title) values (1, 'tester ');
Query OK, 1 row affected (0.01 sec)
Mysql> insert into job (id, title) values (2, 'accountant ');
Query OK, 1 row affected (0.00 sec)
Mysql> insert into job (id, title) values (3, 'developer ');
Query OK, 1 row affected (0.00 sec)
Mysql> insert into job (id, title) values (4, 'CODER ');
Query OK, 1 row affected (0.00 sec)
Mysql> insert into job (id, title) values (5, 'ctor ctor ');
Query OK, 1 row affected (0.00 sec)
Mysql> insert into job (id, title) values (6, 'mediator ');
Query OK, 1 row affected (0.00 sec)
Mysql> insert into job (id, title) values (7, 'proffessor ');
Query OK, 1 row affected (0.00 sec)
Mysql> insert into job (id, title) values (8, 'grammer ');
Query OK, 1 row affected (0.02 sec)
Mysql> insert into job (id, title) values (9, 'developer ');
Query OK, 1 row affected (0.00 sec)
Mysql>
Mysql> select * from job;
+ ------ + ------------ +
| Id | title |
+ ------ + ------------ +
| 1 | tester |
| 2 | accountant |
| 3 | developer |
| 4 | coder |
| 5 | director |
| 6 | mediator |
| 7 | proffessor |
| 8 | programmer |
| 9 | developer |
+ ------ + ------------ +
9 rows in set (0.00 sec)
Mysql> select * from employee;
+ ------ + ------------ + ----------- + ------------ + --------- + ----------- + ------------- +
| Id | first_name | last_name | start_date | end_date | salary | city | description |
+ ------ + ------------ + ----------- + ------------ + --------- + ----------- + ------------- +
| 1 | jason | martin | 1234.56 | toronto | programmer |
| 2 | alison | mathews | 1976-03-21 | 1986-02-21 | 6661.78 | vancouver | tester |
| 3 | james | smith | 6544.78 | vancouver | tester |
| 4 | celia | rice | 1982-10-24 | 2344.78 | vancouver | manager |
| 5 | robert | black | 2334.78 | vancouver | tester |
| 6 | linda | green | 4322.78 | new york | tester |
| 7 | david | larry | 7897.78 | new york | manager |
| 8 | james | cat | 1232.78 | vancouver | tester |
+ ------ + ------------ + ----------- + ------------ + --------- + ----------- + ------------- +
8 rows in set (0.00 sec)
Mysql>
Mysql>
Mysql> create algorithm = temptable view myview
-> (Id, first_name, title)
-> Select o. id, o. first_name, c. title
-> From job c, employee o
-> Where o. id = c. id;
Query OK, 0 rows affected (0.00 sec)
Mysql>
Mysql> select * from myview;
+ ------ + ------------ +
| Id | first_name | title |
+ ------ + ------------ +
| 1 | jason | tester |
| 2 | alison | accountant |
| 3 | james | developer |
| 4 | celia | coder |
| 5 | robert | director |
| 6 | linda | mediator |
| 7 | david | proffessor |
| 8 | james | programmer |
+ ------ + ------------ +
8 rows in set (0.00 sec)
Mysql>
Mysql> drop view myview;
Query OK, 0 rows affected (0.00 sec)
Mysql>
Mysql>
Mysql>
Mysql>
Mysql> drop table job;
Query OK, 0 rows affected (0.02 sec)
Mysql> drop table employee;
Query OK, 0 rows affected (0.00 sec)
Mysql>