Reputation: 205
Here I am trying to fetch products along with prices but here one condition is there that is title should be unique in results.
example: Nokia lumia 730 has three rows but I need to fetch only one row by giving price range in that category.
Please look here for schema
http://sqlfiddle.com/#!9/a28c2/6
Upvotes: 0
Views: 40
Reputation: 98
use the where clause and group by dude...
select * from table where name='Nokia 730' and price between '1000' and '2000' group by title//price range
or
select * from table where name='Nokia 730' and price='1000' group by title//specific price
Upvotes: 1
Reputation: 71
You can use : GROUP BY .
Ex :
SELECT DISTINCT p.* from products AS p LEFT JOIN price AS p1 on p1.product_id=p.id WHERE p1.price >= '2000' AND p1.price <= '10000' AND p.category IN (6) GROUP BY title;
Upvotes: 2