Reason
Reason

Reputation: 59

MySQL select from database not null

I am trying to select information from database but I don't want to select NULL.

My query:

SELECT percent, cost, userid FROM games ORDER BY `percent` ASC LIMIT 5

and it's selecting NULL value, how to don't select NULL.

Example

Upvotes: 1

Views: 30

Answers (2)

Phiter
Phiter

Reputation: 14982

The IS NOT NULL can be used in the WHERE clause.

Read the manuals ;)

SELECT percent,cost,userid
FROM games
WHERE `YourAwesomeColumn` IS NOT NULL
ORDER BY `percent` ASC
LIMIT 5

Upvotes: 0

Alessio Cantarella
Alessio Cantarella

Reputation: 5201

Use a WHERE statement with the IS NOT null operator.

SELECT percent
    , cost
    , userid
FROM games
WHERE percent IS NOT NULL
ORDER BY percent ASC
LIMIT 5

Upvotes: 1

Related Questions