How to select rows where field is not blank/empty

mysql

Solution

SELECT fieldone, fieldtwo
FROM tableone
WHERE fieldone != ''
OR fieldone IS NOT NULL

SELECT fieldone, fieldtwo
FROM tableone
WHERE fieldone <> ''
OR fieldone IS NOT NULL

When you mean NULL value then don't include a space between your '' so it means NO CONTENT

Problem

I'm trying to do a MySQL query in phpMyAdmin. I want to find an entry where fieldone is not NULL or is not empty/blank as I inherited the system so fields are set to NULL and some are just blank. Anyways, Here is the query I'm trying ``` SELECT fieldone, fieldtwo FROM tableone WHERE fieldone != ' ' OR fieldone IS NOT NULL ``` And ``` SELECT fieldone, fieldtwo FROM tableone WHERE fieldone <> ' ' OR fieldone IS NOT NULL ``` Both show an error #1064 on the line that contains ``` WHERE fieldone != ' ' ``` And ``` WHERE fieldone <> ' ' ``` The NOT NULL part works great, its just trying to find any fields that are blank.

Original source