1

I downloaded a database with over 90,000 rows. I need to make an edit to coulomb 2 of all rows by adding _id at the end of the value. I've never used SQL before so I'm not sure if its possible to just go through and add characters to the ends this way. what i have is this:

 SET @i = 01001
 WHILE(@i<93600)
  BEGIN 

        UPDATE NutritionTable
    SET field2 = (field2)"_id"
    WHERE field1=@i

SET @i = @i+1
  END -- WHILE

field2 being the coulomb that needs to be updated, and @id is the row number. I'm getting near "SET":syntax error.

I've searched around for answers but haven't found much in regards to this. Any assistance would be appreciated, and apologies in advance if there is another post for this that I missed... or its some basics I'm missing.

1
  • You should be able to do this with one query. no need to loop through like this. Commented Oct 13, 2014 at 11:01

1 Answer 1

2

You don't need a loop - you can just update all the rows, without a where clause:

UPDATE NutritionTable
SET    field2 = CONCAT(field2, '_id');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.