The SQL below selects distinct rows from a table and inserts them into a third table. It works fine.
There is a third column (STID) that I want to insert into the destination table. In the SourceData table, there is a column name STFP. I need to lookup the value of STFP in a third table, STS table, and get the value of STID. How do I get the value of STID?
INSERT INTO DestinationTable(CTYFP, CTYNAME)
SELECT DISTINCT CTYFP , CTYNAME
FROM SourceData
Just join to the other table:
Note: Your question did not post table column names, so I have guessed. You may have to adjust to suit your actual column names.