Skip to content
Advertisement

Using an Inner Join and returning only 1 record per match on the left

I don’t know why I’m not able to figure this out ATM. Here’s a very contrived example.

The following produces two rows because the join table has two matching values, I just want one value as long as there is a matching record on the right.

results in:

Mix 1

Mix 1

Mix 2

Mix 2

Is there a way to do this in the join clause / without doing a select in the where clase or other options like group by.

Advertisement

Answer

Try “select distinct”. You can also group by the columns that are duplicates and take the max() of columns that have unique values.

Edit: how to filter by breed.breedid without using a where clause.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement