Solved

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

Posted on 2008-10-27
2
1,120 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 500 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

688 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