cyber_alchemist Posted September 29, 2013 Share Posted September 29, 2013 i was making a short php program , and I am stuck in the middle of a error which displays : "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE TOUR.tour_type = u43022694_type.tourtype_id AND tour_year > 1990 ' at line 5" Here is my php code: // select the tour titles titles and there posted from 1990 $query = 'SELECT tour_name, tourtype_lable FROM TOUR LEFT JOIN u43022694_type ON tour_type = tourtype_id AND WHERE TOUR.tour_type = u43022694_type.tourtype_id AND tour_year > 1990 ORDER BY tour_type'; $result = mysql_query($query, $db) or die(mysql_error($db)); //show results echo '<table border="1">'; while ($row = mysql_fetch_assoc($result)) { echo '<tr>'; foreach ($row as $value) { echo '<td>' . $value . '</td>'; } echo '</tr>'; } echo '</table>'; where is my syntax error ??? i checked it many times Quote Link to comment Share on other sites More sharing options...
Solution Ch0cu3r Posted September 29, 2013 Solution Share Posted September 29, 2013 (edited) TOUR LEFT JOIN u43022694_type ON tour_type = tourtype_id AND WHERE TOUR.tour_type = u43022694_type.tourtype_id AND remove the AND at the end of the left join line Also you don't need to compare tour_type and tourtype_id again in the where clause as you're doing this comparison in the left join. Edited September 29, 2013 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
cyber_alchemist Posted September 29, 2013 Author Share Posted September 29, 2013 removed the AND and why was i comparing it 2 times i don't know myself Quote Link to comment 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.