Sql query "not null"

I have a table with colums ids, name, email, message, phone, links and login. The input can be empty (empty).

Its sql query:

$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);

      

with this error

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

      

Its an error with "WHERE login NOT NULL" I know. How am I doing this request correctly?

+3


source to share


3 answers


is absent IS



SELECT * FROM `form` WHERE login IS NOT NULL

      

+10


source


Try IS NOT NULL

instead of justNOT NULL



+1


source


You are looking for:

"WHERE IS NOT A NULL SOMETIMES"

0


source







All Articles