Jump to content

insert into one table using info from another?


onedumbcoder

Recommended Posts

lets say I want to insert into table a six values, 3 of those values need to come from table b.

 

so is there a way I can do this?

 

in my example

 

insert into a(1,2,3,4,5,6) values((Select a,b,c from b WHERE id=1),"he","hy","hu")

 

I want (Select a,b,c from b WHERE id=1) to be treated as three values if possible, so it would ultimately translate

 

values((Select a,b,c from b WHERE id=1),"he","hy","hu") as values(a,b,c,"he","hy","hu")

 

Huh? What do you want the records to look like in the end?

Link to comment
Share on other sites

1-6 are just examples,

 

lets say I have a table food with the fields  name, id, date, creator, country, size

 

so i want to make an insertion

 

insert into food(name,id,date,creator,country,size) values((SELECT name,id,date FROM food WHERE id=3),"mike","usa","5")

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.