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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy record, change field value

Status
Not open for further replies.

automaticbaby

Technical User
Jan 16, 2002
45
US
I have a form which imports records from a csv file. I need to copy records that are based on the file and then copy the same data while only changing one column value.

For example, a column named Product has a value of YZ that was imported. Can I copy all the data from the rows that have Product = YZ and then change the YZ to XY in the inserted rows?

Would this be possible with SQL in one statement?
 
Hi

If you want to update the existing table, use an update query, if you want to create a new table containing a copy of the table but with the Product amended use a make table query

either way one query should do the trick

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
I would like to keep it all in one table, if possible. How would I go about this? How do I build an SQL statement that says take these rows where Product = YZ, change the YZ to XY and append it to the end of the table?

I know how to build simple SQL statements, so I know how to select the rows (SELECT * FROM table WHERE Product ="YZ"), but then how do I say copy and change the value?
 
Hi

Now you asking a slightly different question, but you need something like

INSERT INTO MyTable SELECT "XY" as Product, Field1, Field2 ... WHERE Product = "YZ"

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top