I have the following question: in a table I have a ID
that is related to the other table, but the daughter table has several ID
of the table Father then at the time of doing the INNER JOIN
brings me N records. I'm trying to do a SELECT TOP 1
in the JOIN
but I have not succeeded.
In the table B I have N times the ID_A
, but I want you to just bring me the first.
SELECT * FROM A
INNER JOIN B ON B.ID_A = A.ID_A
So if I do the query in a normal way it brings me several times the same record because in table B there are several records associated with that ID.
Then I tried this:
SELECT * FROM A
INNER JOIN B ON B.ID_A = (SELECT TOP 1 ID_A FROM B WHERE ID_A = A.ID_A)
But I still get the same result, I still throwing the same number of results as the first query. Any ideas?
Thank you.