how do I select among 2 columns ?

2005-09-14 Thread Gilles MISSONNIER
Hello, a simple question : I have a table like this : name, email_1, email_2 and I want to display in a web page name, email_1 if it exists, or email_2 if email_1 do NOT exist. of course I can do this inside a php script, by checking the content of the columns, BUT I had like to get the values

Re: how do I select among 2 columns ?

2005-09-14 Thread Scott Noyes
I have a table like this : name, email_1, email_2 and I want to display in a web page name, email_1 if it exists, or email_2 if email_1 do NOT exist. SELECT name, IF(email_1 IS NOT NULL AND email_1 != '', email_1, email_2) AS email FROM theTable; -- MySQL General Mailing List For list

Re: how do I select among 2 columns ?

2005-09-14 Thread Michael Stassen
Scott Noyes wrote: I have a table like this : name, email_1, email_2 and I want to display in a web page name, email_1 if it exists, or email_2 if email_1 do NOT exist. What if email_2 does not exist, either? SELECT name, IF(email_1 IS NOT NULL AND email_1 != '', email_1, email_2) AS email