It’s almost the same code as in the previous example. To get the matched as well as unmatched rows from a table using the LEFT JOIN, you’ll have to write this code: Let me show you what that means in practice. The LEFT JOIN will do that from the left-hand table, the RIGHT JOIN from the right-hand one. Which one you should use depends on which table you want to keep the unmatched rows from. To get all of the rows from just one of the tables – the matched rows as well as the unmatched rows – you need to use the LEFT JOIN or the RIGHT JOIN. How do you also get the unmatched rows? Get all the Matched and Unmatched Rows From one Table There may be some employees who are not allocated to any projects, and there may be some projects without any employees allocated to them. This, however, means each table may have rows that do not correspond to the other table. In other words, the code returns only the employees that have a project allocated to them. The result shows only the rows from the table employee that match the rows in the table project. Here’s what you get as a result: first_name Note: Of course, you can use either JOIN or INNER JOIN as the keyword – they are the same. To get the employees’ name and the projects they are working on by using the INNER JOIN, you’ll have to write this code: What Happens When you Use the INNER JOIN?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |