Quantcast
Viewing all articles
Browse latest Browse all 6

SQL Server: Join two tables returning only one row from the second table

TABLE1ID (PK) Name 1001 SamTABLE2IDadd (FK) Country 1001 USA 1001 UKMy query:SELECT A.Name, B.CountryFROM TABLE1 AINNER JOIN (SELECT TOP 1 * FROM TABLE2 WHERE IDadd = A.ID) AS BON B.IDadd = A.IDBasically, the query intends to get one of the records from TABLE2 and join it to TABLE1. However, I can't get it to work.Any help is highly appreciated!

Viewing all articles
Browse latest Browse all 6

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>