1

I have a Dossiers table with a print_flag column and i want set print_flag=1 for multiple rows.

UPDATE dossiers SET print_flag = 1 
WHERE id=1013997,id=1020799,id=1020800,id=1020800;

How should the SQL look like?

1

5 Answers 5

3

You should use the IN clause as it'll allow you to use multiple values for a single column.

UPDATE dossiers SET print_flag = 1 
WHERE id IN(1013997, 1020799, 1020800);
Sign up to request clarification or add additional context in comments.

Comments

1

You need IN clause as:

UPDATE dossiers 
SET print_flag = 1 
WHERE id IN (1013997,1020799,1020800,1020800);

Comments

1
UPDATE dossiers 
SET print_flag = 1 
WHERE id IN(1013997,1020799,1020800,1020800);

Comments

1

Use the IN clause. (BTW, i dont think the double of 1020800 is necessary, so i've omitted it.)

   UPDATE dossiers SET print_flag = 1 
   WHERE id IN(1013997, 1020799, 1020800);

Comments

0

If you are sure about the ids you are passing in the query are existed in table than you may try this one :

    UPDATE dossiers SET print_flag = 1 WHERE id IN (1013997,1020799,1020800,1020800);

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.