Jump to content

mysql 4 vs mysql 5? Why does this not work in both?


intrigue

Recommended Posts

[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]
just curious
can u change that RIGHT JOIN to a LEFT JOIN
LEFT 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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.