开发者

Is null condition checking in a select query

Tablename : Employee

select name,age,photopath from employee;

I need to re frame开发者_运维知识库 the query, ie if the photo path is null, then i need to return photo cloumn which is a BLOB.

photopath - will be http://www.servername.com/imagename.html

Thanks.


You can use IF() to check for the condition, and return one of two columns. Possibly in combination with AS to create an unique field name (if that is your goal).


SELECT IF(field1 IS NULL, field2, field1) FROM table1;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜