I have the following tables and I need to remove the rows that satisfy a given condition.
Please help me.
Table: Product
productId productname datecreated
1 sample1 20/01/2012
2 sample1 20/01/2012
3 sample2 20/02/2012
4 sample2 20/02/2012
5 sample2 20/09/2012
6 sample1 20/08/2012
Table: Category
categoryid categoryname
1 cat1
2 cat2
3 cat3
Table: ProductCategory
postid categoryid
1 1
4 2
Now I want to delete the rows which have the count > 1 group by productname
and datecreated
from first table and also the rows that are not contained in the productcategory
table
i.e, I want to remove the
ProductId 2 and ProductId 3
because it has the same ProductName
with same DateCreated
and also is not contained in the ProductCategory
Table
thanks in advance
sql fiddle demo