c_pattle Posted December 1, 2011 Share Posted December 1, 2011 I have the following sql which should return quite a few rows of data but I run it it returns an empty set. Then when I ran the explain function it said there was an impossible where clause. SELECT product_data . * , product_pricing . * , products_to_categories . * FROM product_data, product_pricing, products_to_categories WHERE product_pricing.product_id = product_data.product_id AND product_pricing.sales_price_inc_vat BETWEEN 1.00 AND 2000.00 ORDER BY product_pricing.sales_price_inc_vat DESC LIMIT 20 So the sql should get all the products where the price is within a certain range. Does anyone know what I'm doing wrong? Let me know if you need the table structures but they are pretty big Thanks for any help! Quote Link to comment Share on other sites More sharing options...
kickstart Posted December 1, 2011 Share Posted December 1, 2011 Hi Not sure why you are getting an impossible where clause, but if it did work you would get a massive number of results as it is cross joining against products_to_categories. All the best Keith Quote Link to comment Share on other sites More sharing options...
fenway Posted December 1, 2011 Share Posted December 1, 2011 Stop using theta syntax (comma) and use JOINs. Quote Link to comment Share on other sites More sharing options...
awjudd Posted December 1, 2011 Share Posted December 1, 2011 Stop using theta syntax (comma) and use JOINs. Seconded! 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.