Log in

View Full Version : Resolved IFNULL syntax (complicated)



james438
01-12-2010, 06:38 AM
The following is actually a simplified version of the SQL I am trying to run

SELECT ID, summary, IFNULL(image,0) as mee FROM memoblog WHERE (lcase( concat(cast(ID as
char), summary, image)) LIKE '%yoo%' )

summary='yoo'
image=NULL
ID=3

If any of the columns are NULL the whole thing will be considered NULL. I would like to give "image" a value that is close to NULL without invalidating the whole query. I'm still seeing what I can find. It seems like every example I try from other sites just won't work.

james438
01-12-2010, 06:59 AM
Here is the solution I came up with:


SELECT ID, summary, image FROM memoblog WHERE (lcase( concat(cast(ID as
char), summary, IFNULL(image,''))) LIKE '%yoo%' )
I was sure I had tried this earlier though.