willsherwood
asked on
mySQL IF stmt within SELECT list
I want to accomplish the equivalent of:
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.
if both first and last names are NULL, then substitute "Customer" for the first name
otherwise pass-thru Fname and Lname.
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
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER