I have the following SQL query and want to exclude title and content that is null. I have tried with WHERE title IS NOT NULL
, but obviously that didn't work for me and returns error: Syntax error or access violation
.
The current query
SELECT * FROM entries ORDER BY id DESC LIMIT $postnumbers OFFSET $offset
What i tried
SELECT * FROM entries WHERE title IS NOT NULL ORDER BY id DESC LIMIT $postnumbers OFFSET $offset
What is the correct answer?
Table definition
entries
CREATE TABLE entries (
id int(11) NOT NULL AUTO_INCREMENT,
title varchar(150) DEFAULT NULL,
content longtext,
category int(11) DEFAULT NULL,
status int(11) DEFAULT NULL,
keyword1 varchar(45) DEFAULT NULL,
keyword2 varchar(45) DEFAULT NULL,
likes varchar(45) DEFAULT NULL,
image varchar(45) DEFAULT NULL,
description` varchar(45) DEFAULT NULL,
owner int(30) DEFAULT 0,
page_views int(50) DEFAULT NULL,
time int(20) DEFAULT NULL,
maincategory int(10) DEFAULT NULL,
entriescol varchar(45) DEFAULT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=73 DEFAULT CHARSET=latin1