Jump to content

[SOLVED] query not working well


xiao

Recommended Posts

What I need:

All products with a model starting with 'DVD-FD' OR 'DVD-DH'.

 

My code doesn't return stuff that starts with 'DVD-FD' (it does return the one with 'DVD-DH').

And it also return a product with 'MG....'

$qryProcessor = mysql_query("SELECT p.products_id, p.products_model, p.products_price, pd.products_name FROM products p, 
products_description pd WHERE p.products_id = pd.products_id AND pd.language_id = 1 AND p.products_model LIKE 'DVD-DH%' OR 
p.products_model LIKE 'DVD-FD%' GROUP BY p.products_id ORDER BY p.products_price") or die(mysql_error());

 

I'm using osCommerce if it helps.

Link to comment
https://forums.phpfreaks.com/topic/101751-solved-query-not-working-well/
Share on other sites

Put parenthesis around the OR part:

 

<?php
$qryProcessor = mysql_query("SELECT p.products_id, p.products_model, p.products_price, pd.products_name FROM products p, 
products_description pd WHERE p.products_id = pd.products_id AND pd.language_id = 1 AND (p.products_model LIKE 'DVD-DH%' OR 
p.products_model LIKE 'DVD-FD%') GROUP BY p.products_id ORDER BY p.products_price") or die(mysql_error());
?>

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.