MySQL Forums
Forum List  »  InnoDB

"if" condition in SELECT ?
Posted by: Margarita Barvinok
Date: September 07, 2007 08:38AM

Hello!
I wonder is it possible to write an SQL query to do the following:
There is a table table1 with two fields field1 and field2. Field2 always has some data, field1 - sometimes. I need to select field1, if it's not empty, otherwize - field2.

select (if field1 == NULL then field2 else field1) from table1;

Is this possible in SQL?
I woulld appreciate you help.

Thank you,
-Rita

Options: ReplyQuote


Subject
Views
Written By
Posted
"if" condition in SELECT ?
27071
September 07, 2007 08:38AM
16654
September 07, 2007 08:51AM
11137
September 07, 2007 10:09AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.