Select Everything Where A Certain Field Is Not Empty?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
superwormy
Forum Commoner
Posts: 67
Joined: Fri Oct 04, 2002 9:25 am
Location: CT

Select Everything Where A Certain Field Is Not Empty?

Post by superwormy »

How could I select everything where a certain field is not empty / is not null?

Using MySQL 3.23

Thaniks!
User avatar
Crashin
Forum Contributor
Posts: 223
Joined: Mon May 06, 2002 3:42 pm
Location: Colorado

Post by Crashin »

SELECT * FROM tbl_name WHERE field_name IS NOT NULL :)
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

alternative

Post by phpScott »

if your empty defualt values are not NULL then the following will work

SELECT * FROM tableName WHERE fieldName <>''

phpScott'
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

sorry

Post by phpScott »

sorry about the double message i noticed to late that I had missed the second quote :oops:
superwormy
Forum Commoner
Posts: 67
Joined: Fri Oct 04, 2002 9:25 am
Location: CT

Post by superwormy »

Not a problem dude, thanks for all the help!!!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Re: sorry

Post by twigletmac »

phpScott wrote:sorry about the double message i noticed to late that I had missed the second quote :oops:
You can edit and delete your own posts :roll: :)
faq.php#15

Mac
Post Reply