Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert from 2 tables, one adding to input from first ...

Status
Not open for further replies.

sinbadly

Technical User
Mar 16, 2006
126
0
0
GB
I want to insert into a table field1, field2, field3, from table_one, and I want to add onto the end of field3 from the same field-name in table_two.

Insert into table_one(field1, field2, field3)
Select field1, field2, field3
From table_one

… and then take field3 from table_two and add it onto the end of the text entered from field3 from table_one.

Is this possible, experts? Be grateful to see an example of how it can be managed, please.
 
Thanks, r937, but I don't want the second field to wipe out the first. I need it to add on to the text that arrived with the first.

That, I think, is the tricky part.
 
the second field won't wipe out the value of the first, it would concatenate because that's what you'd tell it to do in the query

however, i think you missed my point

you need to be able to join the rows of table_one and table_two

r937.com | rudy.ca
 
Sorry, Rudi, I probably did miss your point. What has worried me is protecting the information that the first table has put in.

The first few paragraphs of a story appear on the homepage, and the rest is in another mysql table that issues it to appear on a separate page.

The following day, I take the homepage story and its second part, and insert it into a table that feeds current stories to an inside page. These stories are not divided.

I code the first insert, and then manually drop in the second part, for fear that coding it might risk obliterating the first part.

There must be a way of doing this safely, so here I am wondering. I'm not too sure about 'joins' in this case either, though I have worked with them a little while ago. Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top