Skip to content
Advertisement

mysql query question about removing data from columns

Select * from setup_module;
+------------------------------------------+----------------+--------------+
| module                                   | schema_version | data_version |
+------------------------------------------+----------------+--------------+
| Aheadworks_AdvancedSearch                | 1.0.1          | 1.0.1        |
| Amasty_Acart                             | 1.8.0          | 1.8.0        |
| Amasty_Base                              | 1.6.3          | 1.6.3        |
| Amasty_CronScheduleList                  | 1.0.0          | 1.0.0

This is what the table looks like right. I only want to delete the data in the two columns on the right. So let’s say i want to delete the first row Aheadworks_AdvancedSearch columns on the right.

I’m sorry i’m horrible in mysql.

Delete schema_version from setup_module WHERE module = "Aheadworks_AdvancedSearch";
Delete data_version from setup_module WHERE module = "Aheadworks_AdvancedSearch";

Would this be the right syntax? How can i combine as well?

Advertisement

Answer

As commented by Strawberry, it looks like you want an update statement rather than delete. The syntax would be:

update setup_module
set schema_version = null, data_version = null
where module = 'Aheadworks_AdvancedSearch'

This resets columns schema_version and data_version to null on the row(s) whose module is equal to 'Aheadworks_AdvancedSearch'.

On the other hand, if you want to delete the entire row(s), then:

delete from setup_module where module = 'Aheadworks_AdvancedSearch';
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement