We have 2 tables. Lets practice!
Table 1
ID
|
Name
|
1
|
Dan
|
2
|
Bob
|
3
|
Elly
|
Table 2
ID
|
Job position
|
2
|
QA
|
3
|
Dev
|
4
|
Trainee
|
Example: SELECT * FROM table1 INNER JOIN table2 on table1.ID=table2.ID
Result:
ID
|
Name
|
ID
|
Job position
|
2
|
Bob
|
2
|
QA
|
3
|
Elly
|
3
|
Dev
|
Example: SELECT * FROM table1 LEFT JOIN table2 on table1.ID=table2.ID
Result:
ID
|
Name
|
ID
|
Job position
|
1
|
Dan
|
Null
|
Null
|
2
|
Bob
|
2
|
QA
|
3
|
Elly
|
3
|
Dev
|
Example: SELECT * FROM table1 RIGHT JOIN table2 on table1.ID=table2.ID
Result:
ID
|
Name
|
ID
|
Job position
|
2
|
Bob
|
2
|
QA
|
3
|
Elly
|
3
|
Dev
|
Null
|
Null
|
4
|
Trainee
|
Example: SELECT * FROM table1, table2
Result will be always Count(*) from table1 multiply by count(*) from table 2,
so in our example it is 3*3=9
|
|||||||||||||||||||||||||||||||||||||||||||||
Комментариев нет:
Отправить комментарий