mySQL Query JOIN in same table
- by jeerose
Table structure goes something like this:
Table: Purchasers Columns: id | organization | city | state
Table: Events Columns: id | purchaser_id
My query:
SELECT purchasers.*, events.id AS event_id
FROM purchasers
INNER JOIN events ON events.purchaser_id = purchasers.id
WHERE purchasers.id = '$id'
What I would like to do, is obviously to select entries by their id from the purchasers table and join from events. That's the easy part. I can also easily to another query to get other purchasers with the same organization, city and state (there are multiples) but I'd like to do it all in the same query. Is there a way I can do this?
In short, grab purchasers by their ID but then also select other purchasers that have the same organization, city and state.
Thanks.