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?

BAdmin
  • 907
  • 1
  • 10
  • 19
StandardNerd
  • 3,843
  • 6
  • 40
  • 73

5 Answers5

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);
NcDreamy
  • 755
  • 6
  • 14
1

You need IN clause as:

UPDATE dossiers 
SET print_flag = 1 
WHERE id IN (1013997,1020799,1020800,1020800);
Deepshikha
  • 9,358
  • 2
  • 18
  • 20
1
UPDATE dossiers 
SET print_flag = 1 
WHERE id IN(1013997,1020799,1020800,1020800);
Raj
  • 10,433
  • 2
  • 43
  • 50
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);
g2server
  • 4,727
  • 3
  • 27
  • 36
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);