Skip to content
Advertisement

Insist on number of rows on left side of join

I have an issue where I want to join two tables where there is 1 record on the left and many on the right side but only need information from the right that exists in all of those records – in other words, insist on only getting 1:1 not 1:n in my results.

Example, if I run this statement below, I get 2 records for the WHERE statement:

When I include a join to a table which contains more info than returned from the query above, it finds 7 records on the right hand side. So, the results of the statement below results in 2 x 7 = 14 rows.

I still want just 2 records as per the first statement example but with the addition of the column value from the join.

Any ideas?

Advertisement

Answer

You want just any security_name for a bi row, no matter which. Let’s take the minimum (first in the alphabet). The most simple way is to select it in the SELECT clause:

Alternatively in the FROMclause:

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