Link to home
Create AccountLog in
Avatar of willsherwood
willsherwood

asked on

mySQL IF stmt within SELECT list

I want to accomplish the equivalent of:
if both first and last names are NULL,  then substitute "Customer"  for the first name
otherwise pass-thru  Fname and Lname.

I don't think nested    IFNULL  will do it because two fields are being tested but only one returned.

I need in the end to yield two separate fields returned  (First, Last) -- for a salutation (Dear Customer)

something like...   but i can't get the NULL parts right.
SELECT    IF( CONCAT(Fname,Lname) ISNULL ,  "Customer",  Fname) AS FirstName, Lname AS LastName

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of schubach
schubach

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of willsherwood
willsherwood

ASKER

THANK YOU -  that was the trick!