I have 2 tables:
ads :
+------+---------------+
| ID | Name |
+------+---------------+
| 1 | Item 1 |
| 2 | Item 2 |
| 3 | Item 3 |
| 4 | Item 4 |
| 5 | Item 5 |
+------+---------------+
assigned_ads :
+------+-----------+--------------+
| ID | ad_id | location |
+------+-----------+--------------+
| 1 | 3 | place 1 |
| 2 | 2 | place 2 |
| 3 | 1 | place 3 |
+------+-----------+--------------+
As you can see; ad 1,2 and 3 are all assigned to a location. What I need is a query that gets all the the rows in the ads
table that isn't assigned in the assigned_ads
table
You need to use a LEFT OUTER JOIN to do this, as show below: