<title>SQL Example 10–join</title> SQL Example 10–join
Inner joins inside joins
Left [outer] Join # outer can omit right [outer] join # outer can omit
Create Table worker(WIDintAuto_incrementPrimary Key, fnamevarchar(20) not NULL, lnamevarchar(20) not NULL);Create Table Job(Jidint not NULLAuto_incrementPrimary Key, job_namevarchar(20) not NULL);Insert intoWorker (fname, lname)Values(' A ',' A '), (' B ',' B '), (' C ',' C ');Insert intoJob (Job_name)Values(' Cleaner '), (' farmer '), (' Boss ');
- Join
Select from join Job J;
| fname | lname | Job_name |+-------+-------+----------+| A | a | cleaner | | b | b | cleaner | | c | c | cleaner | | A | a | farmer< c15/>| | b | b | farmer | | c | c | farmer | | A | a | boss | | b | b | boss
| | C | C | boss |
Select from Join where w.wid = J.jid;
| fname | lname | Job_name |+-------+-------+----------+| A | a | cleaner | | b | b | farmer | | c | c | boss |
Insert into Values (' d'd ');
Select from Join where w.wid = J.jid;
| fname | lname | Job_name |+-------+-------+----------+| A | a | cleaner | | b | b | farmer | | c | c | boss |
- Left Join
To be continued, occupy a position first <2015-06-14 20:57>
- Right Join
To be continued, occupy a position first <2015-06-14 20:57>
SQL Example-Join