intrigue Posted November 10, 2006 Share Posted November 10, 2006 [pre] $search = "SELECT ct_vehicles.id,". " ct_vehicles.description,". " ct_vehicles.price,". " ct_vehicles.manufacturer,". " ct_vehicles.new,". " ct_sites.county,". " ct_images.id,". " ct_images.vehicleId". " FROM ct_vehicles". " LEFT JOIN ct_sites". " ON ct_vehicles.siteId = ct_sites.id". " RIGHT JOIN ct_images". " ON ct_vehicles.id = ct_images.vehicleId". " WHERE (".$where.")" " LIMIT ".$offset. ",".$rowsPerPage.";"; $where = my condition set (this is correct i think)$offset = Offset set by my paging alongside Rows per Page$rowsPerPage = As above;[/pre]In mysql 5 it displays the correct 35 records where as in mysql 4 it displays some 13000 records WTF.Any help appreciated, here's the output from an actual search.[pre]SELECT ct_vehicles.id, ct_vehicles.description, ct_vehicles.price, ct_vehicles.manufacturer, ct_vehicles.new, ct_sites.county, ct_images.id, ct_images.vehicleId FROM ct_vehicles LEFT JOIN ct_sites ON ct_vehicles.siteId = ct_sites.id RIGHT JOIN ct_images ON ct_vehicles.id = ct_images.vehicleId WHERE (ct_vehicles.description LIKE '%red%' OR ct_vehicles.manufacturer LIKE '%red%' OR ct_vehicles.colour LIKE '%red%' OR ct_vehicles.text LIKE '%red%' ) LIMIT 0,5;[/pre] Quote Link to comment Share on other sites More sharing options...
arianhojat Posted November 10, 2006 Share Posted November 10, 2006 just curiouscan u change that RIGHT JOIN to a LEFT JOINLEFT JOIN ct_images ON ct_images.vehicleId=ct_vehicles.id and add more parens...( (ct_vehicles.description LIKE '%red%') OR (ct_vehicles.manufacturer LIKE '%red%') OR (ct_vehicles.colour LIKE '%red%') OR (ct_vehicles.text LIKE '%red%') ) LIMIT 0,5;honestly dont know, but worth a shot Quote Link to comment Share on other sites More sharing options...
fenway Posted November 10, 2006 Share Posted November 10, 2006 Probably has something to do with the order of precendence in the JOINs.... I would switch to all LEFT JOINs and see what happens. 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.