Link to home
Start Free TrialLog in
Avatar of Bob-Villa
Bob-Villa

asked on

MYSQL IF() USAGE (AS COLUMN IF COLUMN IS NULL)

Need to know if this is possible and how to execute
[id|colA|colB]

colA and colB are similar datatypes (phone number for example)

want to

SELECT colA from TABLE where id>0 ORDER BY colA

but if colA data is NULL use colB and optionally have it sortable.
something like this may explain my thoughts better...
SELECT colA,colB AS colA if colA IS NULL from TABLE where id>0 ORDER BY colA




ASKER CERTIFIED SOLUTION
Avatar of Umesh
Umesh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial