Skip to content
Advertisement

how to match two columns in a join by a third “mapping” table

I’m trying to do a VLOOKUP like join in sql.

I have 3 table:

dest_table: destination_test_name | des_string_result

target_table: enter image description here

map_table: enter image description here

Wanted output: enter image description here

Advertisement

Answer

Yes, you can do this using joins.

select 
    destination_test_name,
    des_string_result,
    target_test_name,
    target_string_result
from 
    map_table 
    inner join dest_table using(destination_test_name)
    inner join target_table using(target_test_name);
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement