sql - Use two queries to populate table with INSERT statement -
could elucidate me why following not work:
insert druginteractions(ndc_fk, ndc_pk) (select top 1 ndc druglist drug_name 'cipro%'), (select top 1 ndc druglist drug_name 'tizan%')
the column ndc
in druglist
primary key uniquely identifies drug. since need 2 things interact druginteractions
table has 2 copies of ndc
; these 2 ndc
s composite primary key. drug has ndc of 1 , drug b has ndc of 2, row in druginteraction like:
ndc_pk ndc_fk 1 2
is there way populate table using insert statement 2 queries, 1 each column i'm trying? error is:
msg 102, level 15, state 1, line 2
incorrect syntax near ','
you need use values
combine them;
insert druginteractions(ndc_fk,ndc_pk) values( (select top 1 ndc druglist drug_name 'cipro%'), (select top 1 ndc druglist drug_name 'tizan%') )
Comments
Post a Comment