acer88 Posted October 29, 2006 Share Posted October 29, 2006 I get this error when trying to do a mysql query with select.Here is the error I get: SELECT Error: 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 'select barcode from itemdescription) order by listing.date DESCand here is the code that I believe is generating the error: //$records = mysql_query( "SELECT * FROM listing where title like '%$title%' and barcode in (select barcode from itemdescription) order by date DESC")$records = mysql_query( "SELECT listing.recordid,listing.barcode,listing.itemnumber,listing.title,listing.inputdate,itemdescription.category,category.categoryname FROM listing left join itemdescription on listing.barcode=itemdescription.barcode left join category on itemdescription.category=category.categoryid where listing.title like '%$title%' and listing.barcode in (select barcode from itemdescription) order by listing.date DESC")or die("SELECT Error: ".mysql_error());$num_rows = mysql_num_rows($records);what is wrong with my syntax?? Sometimes it just take another pair of eyes to spot the problem:) Thanks Quote Link to comment https://forums.phpfreaks.com/topic/25526-help-with-select-syntax/ Share on other sites More sharing options...
fenway Posted October 29, 2006 Share Posted October 29, 2006 What MySQL version are you using? It looks like it's not happy with your subqueries, though there could be another syntax error there somewhere. Quote Link to comment https://forums.phpfreaks.com/topic/25526-help-with-select-syntax/#findComment-116494 Share on other sites More sharing options...
acer88 Posted October 30, 2006 Author Share Posted October 30, 2006 our hosting is through godaddy and they are using version 4.0.24 Quote Link to comment https://forums.phpfreaks.com/topic/25526-help-with-select-syntax/#findComment-116507 Share on other sites More sharing options...
fenway Posted October 30, 2006 Share Posted October 30, 2006 No subquery support until 4.1... though you could rewrite these as JOINs:[code]SELECT * FROM listing INNER JOIN itemdescription USING barcode WHERE listing.title like '%$title%' ORDER BY listing.date DESC[/code] Quote Link to comment https://forums.phpfreaks.com/topic/25526-help-with-select-syntax/#findComment-116816 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.