Solved

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

Posted on 2008-10-27
2
1,115 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
2 Comments
 
LVL 142

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

895 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now