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]
Link to comment
Share on other sites

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.