[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Phpgroupware-developers] Contact function for SQL (howto in mssql)
From: |
Brian Johnson |
Subject: |
Re: [Phpgroupware-developers] Contact function for SQL (howto in mssql) |
Date: |
Sat, 13 Sep 2003 03:46:19 +0000 |
Found out something today. pgsql, mysql, and mssql all support the CASE
statement
in sql
It might be good to keep the code as standard as possible (even though we are
using
the db specific concat functions, someday they might merge on one standard) and
use
the CASE function instead of COALESCE() or ISNULL() or IFNULL()
http://www.postgresql.org/docs/7.2/interactive/functions-conditional.html
http://www.mysql.com/doc/en/Control_flow_functions.html
http://dbforums.com/t907538.html
Example:
SELECT a,
CASE WHEN a IS NOT NULL THEN a
ELSE ''
END
FROM test;
Edgar Luna (address@hidden) wrote:
>
>"Chris Weiss" <address@hidden> writes:
>
>> SELECT RTRIM(ISNULL(last_name,'')) + RTRIM(ISNULL(org_name,'')) + ... as
>> name ...
>
>> The RTRIM is needed to remove any whitespace otherwise you get something like
>> "name
>> orgname
>> "
>Ok, I'll code that then.
>
>Thanks a lot.
>
>
>
>_______________________________________________
>Phpgroupware-developers mailing list
>address@hidden
>http://mail.gnu.org/mailman/listinfo/phpgroupware-developers
>