Well, I have two tables:
events:id,title,descriptiontrip_events:id,event_id(points toevents.id)
I need to select results from table named events.
SELECT *
FROM `events`
Simple as that, right?
The thing I need to achieve is that I need to select results from events, but exclude those rows that are in trip_events (if events.id != trip_events.event_id the excluded).
Here is example:
events:
id:5,id:6,id:7,id:8;
trip_events:
event_id:6,event_id:8;
With this data-set, only events with id as 5 and 6 would be returned.
How to do this?
I tried like this:
SELECT *
FROM `events`
JOIN `trip_events`
ON (`trip_events`.`event_id` = `events`.`id`)
WHERE `trip_events`.`event_id` != `events`.`id`
But it didn’t work.
Edit:
As a side note, the
ONcondition can be thought of as aWHEREcondition. The result of your query would be the same as the followingGuess why you don’t get any results!