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
  • 927
  • 1
  • 11
  • 19
StandardNerd
  • 4,093
  • 9
  • 46
  • 77

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
  • 785
  • 6
  • 14
1

You need IN clause as:

UPDATE dossiers 
SET print_flag = 1 
WHERE id IN (1013997,1020799,1020800,1020800);
Deepshikha
  • 9,896
  • 2
  • 21
  • 21
1
UPDATE dossiers 
SET print_flag = 1 
WHERE id IN(1013997,1020799,1020800,1020800);
Raj
  • 10,653
  • 2
  • 45
  • 52
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
  • 5,037
  • 3
  • 29
  • 40
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);