Solved

MySQL - I don't understand

Posted on 2014-12-11
2
197 Views
Last Modified: 2014-12-11
See attached. This is a small sample of a table (named "customer") that I have.

Notice the column called cutype in most cases the value is NULL (in italics), I don't know what that means.

I run this query: DELETE from customer where cutype <> 'i'

It deletes the 79 rows that have blank (not NULL) in the column.

It leaves all the rest.

Actually, at this moment, there are NO rows in the table where cutype = 'i'.

Why does it leave the NULL ones? That is not a value of 'i'.

Thanks
cutype.jpg
0
Comment
Question by:Richard Korts
2 Comments
 
LVL 24

Accepted Solution

by:
mankowitz earned 500 total points
ID: 40495213
Null isn't really an empty value so much as it is the absense of any value. The way to check for null is by using IS NULL. For example, to delete rows where cutype is null, you'd have to do this:

DELETE FROM customer WHERE cutype IS NULL;

if you want to get rid of anything that is either null or NOT i, do this:

DELETE FROM customer WHERE cutype IS NULL OR cutype <> 'i';
0
 
LVL 58

Expert Comment

by:Gary
ID: 40495214
NULL values are a bit special
http://dev.mysql.com/doc/refman/5.1/en/working-with-null.html

If you want to delete rows with NULL values you have to declare them

    DELETE from customer where cutype <> 'i' OR cutype IS NULL
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Insert command generates error in MySQL 3 49
How do i connect MySQL on Visual Studio 3 54
Coldfusion- Create and save form elements in Database 7 61
html input clean up 3 47
Fore-Foreword Today (2016) Maxmind has a new approach to the distribution of its data sets.  This article may be obsolete.  Instead of using the examples here, have a look at the MaxMind API (https://www.maxmind.com/en/geolite2-developer-package). …
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.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 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

20 Experts available now in Live!

Get 1:1 Help Now