If I have multiple entries in a cloumn in mysql that need to be changed

48 Views Asked by At

So I want to change all the fields in the column allow_two_day_ordering to False. How can I change them all without doing it one by one. I have a much bigger list than this.

+-------+--------------------------------------+------------------------+
| ID    | Venue_id                             | allow_two_day_ordering |
+-------+--------------------------------------+------------------------+
| 26862 | 099B4758-2D0B-E411-9406-00155DCFC111 | TRUE                   |
| 26865 | 4fcdf8dd-2f0b-e411-9406-00155dcfc111 | TRUE                   |
| 26868 | 9e4b1850-330b-e411-9406-00155dcfc111 |                        |
| 26871 | bb0ed477-360b-e411-9406-00155dcfc111 | TRUE                   |
| 26874 | 89d6b4c7-350b-e411-9406-00155dcfc111 |                        |
| 26877 | a40d0646-340b-e411-9406-00155dcfc111 | TRUE                   |
| 26880 | e6693bac-330b-e411-9406-00155dcfc111 | TRUE                   |

I think my query would be something like so:

UPDATE venue_locations set allow_two_day_ordering = FALSE WHERE ID = '26862,26865,26868';

Like so?

1

There are 1 best solutions below

5
Tangentially Perpendicular On

If you really want to set all the values to false you can do this:

UPDATE venue_locations set allow_two_day_ordering = FALSE;

Note: No WHERE clause, so all rows will be selected.

[Update, in response to question updates]

If you have a list you can do this:

UPDATE venue_locations set allow_two_day_ordering = FALSE WHERE ID IN (26862,26865,26868);

The IN clause can work well for short lists and smaller tables. It can be slow for larger tables, but for a one-time update it'll probably be acceptable.

If you want to reset all the TRUE values to FALSE:

UPDATE venue_locations set allow_two_day_ordering = FALSE where allow_two_day_ordering = TRUE;