row248
row248

Reputation: 119

Sql request "not null"

I have table with colums id, name, email, message, phone, links and login. Login can be null(empty).

Its my sql request:

$dbh = new PDO("mysql:host=$dbHost;dbname=$dbName", $dbUser, $dbPassword);
$sth = $dbh->query('SELECT * FROM `form` WHERE login NOT NULL ');
$sth->setFetchMode(PDO::FETCH_ASSOC);

whith this error

 Call to a member function setFetchMode() on a non-object

Its error with "WHERE login NOT NULL", i know. How me correctly make this request?

Upvotes: 3

Views: 119

Answers (3)

moudrick
moudrick

Reputation: 2336

Try IS NOT NULL instead of just NOT NULL

Upvotes: 1

EtherKnight
EtherKnight

Reputation: 34

You're looking for:

"WHERE login IS NOT NULL"

Upvotes: 0

Raphaël Althaus
Raphaël Althaus

Reputation: 60493

missing an IS

SELECT * FROM `form` WHERE login IS NOT NULL

Upvotes: 10

Related Questions