SQL: Insert multiple row with common columns -


i have table insert , has 4 columns. while inserting 3 columns same , other 1 column different each , taken table. how that? exmaple; insert sendmsg (type,name,sendername,message) values(4, 'john','mike','hi, blabla')

i insert same message bob, instead of john. , names send contained in names table.

thank you.

use select statement build insert. work (as didn't provide more details):

insert sendmsg (type,name,sendername,message)  select 4, "name" ,'mike','hi, blabla' anothertable -- ....  

column names in ", don't confused. it's ensure difference between string , database object. inside optinal maybe

where name in ('bob', 'john', ...) 

or whichever algorithm need determine names.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -