I have a table with several columns (and thousands of rows). I am trying to make a new set of rows work over several shops, so I need to copy a group of rows, change one column, and then reinsert them into my table (the column I'm changing is a key, so that's not a problem).
So far, I've gotten to this point:
INSERT INTO TableName( Column1, Column2, Column3, Column4, Column5, Column6)
(SELECT Column1, Column2, Column3, Column4, Column5, 'NewShopCode'
FROM TableName
WHERE Column5 = 'DistinguishingValue'
For each new shop, I need to do this for two different 'DistinguishingValue's, and I have about ten different 'NewShopCode's.
I have tried ('NewShopCode1', 'NewShopCode2') in place of the single literal insert above, as well as using VALUES before my SELECT statement. Neither of these work, returning a syntax error in each case.
Also, while, in this instance, it's not too much of a hassle to just do two separate queries for DV1 and 2, it would be nice if I could incorporate that into the one single query as well.
For clarification, I know I could just do the query 10 times with copy and paste and it would be pretty quick, and I totally would if it were just a database that I used around my office. Unfortunately, this is an update I need to script and send out to all my customers with the next version release of our software; ergo, single query = less phone calls complaining about how nobody's database works since it didn't update correctly.
Thanks in advance for your consideration.