How to query without receiving duplicate data?

I have a query that has a join in another table:

select * from tbl_scales s
join tbl_recipes r on r.category_id = s.product_id

and displays redundant data such as

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 do not know how to do that. Can anybody help me?

+3
source share
2 answers

SELECT DISTINCT will delete rows that have the same data in columns. But since your date is different, you probably want to use GROUP BY recipe_name (add at the end of your query).

+3
source

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
+1
source

All Articles