I have a query which has a join on another table:
select * from tbl_scales s
join tbl_recipes r on r.category_id = s.product_id
and it displays redundant data like this,
scale_id r_id date recipe_name
1 1 2012-05-20 Cheese Bread
6 1 2012-05-21 Cheese Bread
1 1 2012-05-20 Spanish Bread
6 1 2012-05-21 Spanish Bread
3 4 2012-05-20 Pancake
8 4 2012-05-21 Pancake
1 1 2012-05-20 Pandesal
6 1 2012-05-21 Pandesal
i don't know how to do this..can someone help me?
SELECT DISTINCT will eliminate rows that have equal data in columns. But since your date is different you probably want to use GROUP BY recipe_name (add on the end of your query).
The distinct keyword is your friend.
select distinct r_id, scale_id, recipe_name from tbl_scales s
join tbl_recipes r on r.category_id = s.product_id
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With