[thelist] SQL CASE
Chrome
admin at chrome.me.uk
Fri Sep 26 04:32:31 CDT 2008
Hi all
This is probably something stupid that I've done and can't see... I'm trying
to use a CASE statement to detect a null value and return a value based on
it
Here's the devastatingly simple code I've tried
SELECT
logo AS logo_url,
CASE logo
WHEN NULL THEN 'This is NULL';
WHEN NOT NULL THEN 'This is not NULL';
END CASE
FROM
jos_affiliateMain
WHERE
affiliate_account_id = 1;
I've tried omitting the semicolons from the WHEN statements and I've tried
using logo_url instead of logo in the CASE bit but all I get are syntax
errors (really unhelpful ones: error next to '' on line blah)... I've also
tried things like WHEN '' blah
Can anyone see what I've naffed up? Do I need more caffeine?
Cheers in advance
Dan (who's really glad it's Friday)
More information about the thelist
mailing list