Forum Moderators: open
The above retrieves two results and both contain event_id and location_id - presumably the UNION builds the collumn venue_id into event_id?
What I am trying to achieve is for venue_id to stay as venue_id.
I hope I have made myself clear enough, please bare with me as I have only used basic selects before.
Is there any alternative I can use or changes to my code?
Cheers
SELECT 'event' AS idType, event_id, location_id FROM events WHERE url='$pageurl'
UNION
SELECT 'venue' AS idType, venue_id, location_id FROM venues WHERE url='$pageurl
If you want to see both the event_id and the venue_id, then you must do a JOIN.
Noting that location_id is in both tables, you could do something like:
SELECT events.event_id, events.location_id, venues.venue_id
FROM events JOIN venues ON events.location_id = venues.venue_id