xiao Posted April 18, 2008 Share Posted April 18, 2008 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 More sharing options...
GingerRobot Posted April 18, 2008 Share Posted April 18, 2008 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()); ?> Link to comment https://forums.phpfreaks.com/topic/101751-solved-query-not-working-well/#findComment-520590 Share on other sites More sharing options...
xiao Posted April 18, 2008 Author Share Posted April 18, 2008 niiiice, thanks a lot Link to comment https://forums.phpfreaks.com/topic/101751-solved-query-not-working-well/#findComment-520594 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.