I have 2 tables filled automatically by cronjobs (an events table and a location table with the addresses of the events. Because both feeds are different, sometimes the events are linked to the locations via location_id1, but sometimes with location_id2, like such:
locations table:
id imported_id1 imported_id2 address
1 NULL 20 xx
2 10 NULL xx
...
events table:
id location_id1 location_id2 some_data
1 NULL 20 xx
2 10 NULL xx
...
To select the events and get the correct address to the location it's linked to, I tried a JOIN like this, but the OR makes the query run SO MUCH slower:
SELECT * FROM events
JOIN locations ON
events.location_id1 = locations.limported_id1
OR events.location_id2 = locations.limported_id2;
Anyone has a better way to query this?