?
Solved

MySQL query - change the value of a field in multiple id's

Posted on 2008-10-27
2
Medium Priority
?
1,121 Views
Last Modified: 2012-06-27
Hi,

The last half an hour has confirmed to me that I know so little when it comes to MySQL.  I have been trying to update the value of a column (guest_account) in a table (customers) where guest_account = NULL.  The updated value should be 0.  In other words, in the customers table, change the value of all entries in the guest_account column/field from NULL to 0, but only if they equal NULL.

Here's what I thought would work (but doesn't):
UPDATE `customers` SET `guest_account` = '0' WHERE `guest_account` = NULL;

Open in new window

0
Comment
Question by:Treder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 22817303
NULL is special, but you where close:

UPDATE `customers` SET `guest_account` = '0' WHERE `guest_account` IS  NULL;

Open in new window

0
 

Author Comment

by:Treder
ID: 22817419
You're an angellll :) Sorry for the cliche!
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question