SQL Vlookup! (1 Viewer)

Joy83

Member
Local time
Yesterday, 18:25
Joined
Jan 9, 2020
Messages
116
Hi,
I need your help
I have a table (table1) that consists of 300 records
I need to match few fields from two other tables (table2) (table3)
Those tables might have duplicates records but the fields I need are the same even in the duplicated records.
I tried right join and left join but it’s not working it brings extra records
I just need the 300 from table 3 matched with some data from the others

Can you please help
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 09:25
Joined
May 7, 2009
Messages
19,237
you may try:

SELECT TABLE1.* ,
(SELECT TOP 1 FIELDY FROM TABLE2 WHERE TABLE2.FK = TABLE1.ID) AS FIELDY ,
(SELECT TOP 1 FIELDZ FROM TABLE3 WHERE TABLE3.FK = TABLE1.ID) AS FIELDZ
FROM TABLE1
 

Joy83

Member
Local time
Yesterday, 18:25
Joined
Jan 9, 2020
Messages
116
you may try:

SELECT TABLE1.* ,
(SELECT TOP 1 FIELDY FROM TABLE2 WHERE TABLE2.FK = TABLE1.ID) AS FIELDY ,
(SELECT TOP 1 FIELDZ FROM TABLE3 WHERE TABLE3.FK = TABLE1.ID) AS FIELDZ
FROM TABLE1
Thank you soooo much
It worked
 

Users who are viewing this thread

Top Bottom