wemustdesign Posted June 12, 2010 Share Posted June 12, 2010 I am joining 2 tables. This query word fine: $query = "SELECT site_users.firstName, site_users.telephone, students.places, students.paymentType, students.paymentStatus "."FROM site_users LEFT JOIN students". "ON site_users.username = students.user"; I now want to only show results that match up to the field $courseID. I tried this but just got an error: $query = "SELECT site_users.firstName, site_users.telephone, students.places, students.paymentType, students.paymentStatus "."FROM site_users LEFT JOIN students WHERE course = $courseID". "ON site_users.username = students.user"; Quote Link to comment https://forums.phpfreaks.com/topic/204570-join/ Share on other sites More sharing options...
Mchl Posted June 12, 2010 Share Posted June 12, 2010 WHERE clause has to be placed after JOIN ... ON ... clause Quote Link to comment https://forums.phpfreaks.com/topic/204570-join/#findComment-1071130 Share on other sites More sharing options...
wemustdesign Posted June 13, 2010 Author Share Posted June 13, 2010 Thanks for the reply, that worked: $query = "SELECT site_users.firstName, site_users.telephone, students.places, students.paymentType, students.paymentStatus "."FROM site_users LEFT JOIN students "."ON site_users.username = students.user WHERE students.course = '$courseID'"; Quote Link to comment https://forums.phpfreaks.com/topic/204570-join/#findComment-1071408 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.