hey guys so im really struggling with selecting data from 3 tables
so what ive tried to do is:
SELECT c.id,c.name,g.id,g.event_id,e.event_id FROM contact c INNER JOIN guest g ON g.id = c.id LEFT JOIN event e ON g.event_id = e.event_id
but no data appears nor any errors or notices or warning.
i want to get c.name and c.id from contact where c.id = g.id and where e.event_id = g.event_id(i need this coz im using a drop down list to select the names and display, the drop down list is populated by event_name)
Are Contact ID and Guest ID the foreign keys? I'm not seeing anything wrong with your SQL, so the only thing I can think of is they aren't matching.
LEFT OUTER JOIN will get all data from the left table and only associated data from the right table. If there is nothing in "guest" associated with records in "contact" you'll still get data from "contact".
i got it. sorry guys, it had smtg to do with the ajax not the query. blush thanks though. at least i know im doing my query correctly.
No worries. Always remember to test your SQL on your server before thinking that's the issue.
This topic is now closed. New replies are no longer allowed.