mysql - Ce qui suit#39; est la différence entre INNER JOIN, LEFT JOIN, RIGHT JOIN et FULL JOIN

Mots clés : mysqljoininner-joinouter-joinmysql

meilleur 2 Réponses mysql - Ce qui suit#39; est la différence entre INNER JOIN, LEFT JOIN, RIGHT JOIN et FULL JOIN

vote vote

99

id  firstName                  lastName ....................................... 1   arun                        prasanth                  2   ann                         antony                    3   sruthy                      abc                       6   new                         abc                                            
id2 age Place ................ 1   24  kerala 2   24  usa 3   25  ekm 5   24  chennai 
SELECT table1.column1, table2.column2...   FROM table1  INNER JOIN table2     ON table1.common_field = table2.common_field; 
SELECT TableA.firstName,TableA.lastName,TableB.age,TableB.Place   FROM TableA  INNER JOIN TableB     ON TableA.id = TableB.id2; 
firstName       lastName       age  Place .............................................. arun            prasanth        24  kerala ann             antony          24  usa sruthy          abc             25  ekm 
SELECT table1.column1, table2.column2...   FROM table1   LEFT JOIN table2     ON table1.common_field = table2.common_field; 
SELECT TableA.firstName,TableA.lastName,TableB.age,TableB.Place   FROM TableA   LEFT JOIN TableB     ON TableA.id = TableB.id2; 
firstName                   lastName                    age   Place ............................................................................... arun                        prasanth                    24    kerala ann                         antony                      24    usa sruthy                      abc                         25    ekm new                         abc                         NULL  NULL 
SELECT table1.column1, table2.column2...   FROM table1  RIGHT JOIN table2     ON table1.common_field = table2.common_field; 
SELECT TableA.firstName,TableA.lastName,TableB.age,TableB.Place   FROM TableA  RIGHT JOIN TableB     ON TableA.id = TableB.id2; 
firstName                   lastName                    age     Place ............................................................................... arun                        prasanth                    24     kerala ann                         antony                      24     usa sruthy                      abc                         25     ekm NULL                        NULL                        24     chennai 
SELECT table1.column1, table2.column2...   FROM table1   FULL JOIN table2     ON table1.common_field = table2.common_field; 
SELECT TableA.firstName,TableA.lastName,TableB.age,TableB.Place   FROM TableA   FULL JOIN TableB     ON TableA.id = TableB.id2; 
firstName                   lastName                    age    Place ............................................................................... arun                        prasanth                    24    kerala ann                         antony                      24    usa sruthy                      abc                         25    ekm new                         abc                         NULL  NULL NULL                        NULL                        24    chennai 
vote vote

86

window.location.pathname => /search  window.location.href   => www.website.com/search#race_type=1 

Questions similaires