1

I need to get the records where "fulltext" is empty.

This is wha I tried:

SELECT * FROM `j30_k2_items` WHERE 'fulltext'= ' '
SELECT * FROM `j30_k2_items` WHERE 'fulltext'= ''
SELECT * FROM `j30_k2_items` WHERE 'fulltext' IS NULL

They all return an empty query although there are lots of records that match the query.

1 Answers1

1

You can use TRIM function:

SELECT * 
FROM `j30_k2_items` 
WHERE TRIM(`fulltext`)= '' OR `fulltext` IS NULL

to get records that contains only whitespaces or are NULL.

Lukasz Szozda
  • 162,964
  • 23
  • 234
  • 275
  • #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'fulltext)= '' OR fulltext IS NULL ORDER BY `j30_k2_items`.`fulltext` ASC LIMIT' at line 3 –  Nov 10 '15 at 14:43
  • @NunoNogueira Try with backtick – Lukasz Szozda Nov 10 '15 at 14:43
  • 1
    `FULLTEXT` is a reserved word – Hanky Panky Nov 10 '15 at 14:44
  • http://stackoverflow.com/questions/8470813/how-do-i-check-if-a-column-is-empty-or-null-in-mysql check this – Robert Nov 10 '15 at 14:44
  • @fancyPants Can you elaborate? – Lukasz Szozda Nov 10 '15 at 14:45
  • 2
    Well, the answer is in the duplicate question. And it would be nice if you would rather make use of your reputation points to vote to close such questions than answering the same question for the hundredth time. – fancyPants Nov 10 '15 at 14:47