Issues with datebase returning multiples of the same record

Another day and another project.
Issues I am having is the database is returning multiples of the same product.
I have selected ‘DISTINCT’ but for some reason this is just not working.
I’ve tried multiple things but it just is still happening .

Any guru help would be appreciated.

This is the page

Ideally need to see query but try adding a group by on the item id in the query (easiest way is adding and aggregate like count()) , that normally sorts that sort of issue, Distinct works in mysterious ways!

Not sure if this will be any help to.
What to you mean by: adding a group by on the item id in the query (easiest way is adding and aggregate like count())

Forgive me for my dumbness, but I’m still learning things :slight_smile:

No problem

add something like this

(substituting Products.prodID of course)

This forces a “group by” in the query which should remove duplicates created by the RIGHT JOIN. The name given is irrelevant, it just makes it unique from the real prodID.

Gave that a try and added it the Query, but still the same issue of it showing repeated products. Pretty frustrating.
Not sure if I have done it correctly.

Perhaps there are duplicates in the database?

I suspect the duplicates are coming from the fact that you are using a right join and there are multiple foreign keys in either the department or category tables resulting in multiple entries. Should this be a right join?
p.s. shouldn’t;'t need the distinct if using the “group by”

1 Like

So I’ve managed to fix it. Here what I did;
Moved the initial table to be department and products to be the join on the department ID.
Added the Aggregate on the product ID
and hey presto it worked :slight_smile:
I think it must have been something to do with the joins as it was returning 14 duplicates of products ( and no they are not duplicated in the DB)
cheers for the help @Hyperbytes it pointed me in the right direction with a fresh se of eyes.
As I say I’m doing much more with Wappler than what used to do with dreamweaver,

1 Like