sql - inserting multiple rows with varying data with one query -


so .. want have query creates multiple rows 1 query. want

row 1: col1 = 'val1', col2 = 'val2', col3 = 'val3' row 2: col1 = 'val1', col2 = 'val2', col3 = 'val4' row 2: col1 = 'val1', col2 = 'val2', col3 = 'val5' 

where

val3,val4,val5 

are returned sub-query. thinking

insert  table_name (col1, col2, col3) values ('val1', val2, (select column_name table_two condition)); 

any ideas how can 1 query?

yes, it's possible: if val1 , val2 constant, then:

insert table_name (col1, col2, col3) select 'val1', 'val2', column_name table_two condition; 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -