Incorrect parameter when using IsNull in MySQL

I am trying to use a function IsNull()to make sure there is a value for a field.

SELECT crawled.id,
       IsNull(sranking.score,0) as Score,
       crawled.url,
       crawled.title,
       crawled.blurb
FROM crawled
    LEFT JOIN sranking ON crawled.id = sranking.sid
WHERE crawled.body LIKE '%".$term."%'
ORDER BY Score DESC LIMIT " . $start . "," . $c

But I get an error message:

Invalid parameter counter in call to native 'IsNull' function

Does anyone have any ideas? I am new to MySQL.

+3
source share
2 answers

ISNULL checks if the passed expression is NULL. You need IFNULL or COALESCE, as mentioned xyld.

SELECT crawled.id, IFNULL(sranking.score, 0) as Score, ...
+9
source
+2

Source: https://habr.com/ru/post/1744422/


All Articles