Simple RIGHT JOIN solution | Easy and Simple Explanation | NO SUBQUERY
\n# Write your MySQL query statement below\nSELECT s.name \nFROM Orders AS o\n\nINNER JOIN Company AS c\nON c.com_id=o.com_id AND c.name="RED"\n\nRIGHT JOIN Sal
```\n# Write your MySQL query statement below\nSELECT s.name \nFROM Orders AS o\n\nINNER JOIN Company AS c\nON c.com_id=o.com_id AND c.name="RED"\n\nRIGHT JOIN SalesPerson AS s\nON s.sales_id=o.sales_id\n\nWHERE o.sales_id IS NULL;\n```\n\n**Explanation:**\n```\nINNER JOIN Company AS c\nON c.com_id=o.com_id AND c.name="RED"\n```\nThis two line is used to create a view for just **\'RED\' orders**.\nThe **INNER JOIN** or you can also write **JOIN** only, both works the same, is used to JOIN the Company table with the Orders table.\nIt is joined on the name which are **RED** **com_id** as **com_id is a foreign key to com_id from the Company table.**\n\n```\nRIGHT JOIN SalesPerson AS s\nON s.sales_id=o.sales_id\n```\nI have used **RIGHT JOIN** on **sales_id** as **sales_id is a foreign key to sales_id from the SalesPerson table.**\n\nThe right join ensures all salespersons are included (even those who do not have RED orders).\n\n```\nWHERE o.sales_id IS NULL;\n```\nThis line will give us the salespersons who did not have any RED orders due to the right join.\n.\n.\n.\n.\n.\nThanks @Joy4fun & @josephwibowo for this solution and explanation.
['MySQL']