views:

49

answers:

2
SELECT Concat(mp.cHospital ,',',mp.cHospital1,',',mp.cHospital2) as Hospital FROM TBL

I dont want to return null value,

how to check not null or how to make isset cond in query

A: 

You may use case condition for this http://dev.mysql.com/doc/refman/5.0/en/case-statement.html

lfx
+3  A: 

By definition (almost)any operation with NULL will result in NULL as NULL means "undfined". I interpret your question that either cHospital or cHospital1 or cHospital3 might be NULL which you want to check. The question is: what should happen? You want just the field replaced with an empty stirng and then the concat or all?

I assume the first. that might look like this:

SELECT Concat(
    IFNULL(mp.cHospital, ''),
    ',',
    IFNULL(mp.cHospital1,''),
    ',',
    IFNULL(mp.cHospital2,'')) AS Hospital
FROM TBL

IFNULL returns the first part, unless its NULL where it returns the second part(empty string here).

http://dev.mysql.com/doc/refman/5.1/en/control-flow-functions.html#function_ifnull

johannes
![alt text][1]see screen shot plz [1]: http://img407.imageshack.us/img407/711/mysqlconcatprob.jpg
Bharanikumar
I don't know what you want.
johannes
i tried the above if null condition , even it throughing the null ans
Bharanikumar