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;
精彩评论