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 ndcs 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%') ) 

an sqlfiddle test with.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -