Solved

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

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

Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Duplicated data in GROUP_CONCAT 2 49
BIG DATA Question: Path to migrate current "Document Management" system 13 70
Sql case statement to calculate totals 5 53
SQL query 7 48
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Creating and Managing Databases with phpMyAdmin in cPanel.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

737 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