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 Link to comment https://forums.phpfreaks.com/topic/282525-my-sql-syntax-error/ Share on other sites More sharing options...
Ch0cu3r Posted September 29, 2013 Share Posted September 29, 2013 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. Link to comment https://forums.phpfreaks.com/topic/282525-my-sql-syntax-error/#findComment-1451664 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 Link to comment https://forums.phpfreaks.com/topic/282525-my-sql-syntax-error/#findComment-1451717 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.