I have a product with a field that's a boolean value "Contains Gluten" which stores a "1" for yes and a "0" for no, this is stored in the database as field_contains_gluten_value.

The client now wants it to say "Gluten Free" instead.

Rather than change all of my views and product displays to negate, I figure it would be easier to just flip the value in the database.

I am using feeds to import the products from a csv, but the client has edited products now and changed other fields, so I don't want to change it in excel and import over the top for fear of losing his changes.

In the database how do I change all the "0" values to "1" and vice versa? I'm aware this might not qualify as a Drupal question and might be better on stack overflow, but if there is a Drupal solution you are aware of then I'm all ears!

2 Answers 2


The SQL would be something like:

UPDATE [field table] SET [field column name]=1 WHERE [field column name]=0

Always the way. Post a question and find an answer immediately.

I simply exported the table field_contains_gluten_value from phpmyadmin, opened it up in notepad++ and used find and replace to swap the "1" and "0" values to the correct way.

I then dropped the table in the database, and uploaded the newly edited one in its place.

I'm there was an easier way to do that in SQL, but in this case it took me less than 5 minutes to do over 1000 products. Seems simple enough to me!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.