Can you add “IF” statement in PHP MYSQL ORDER BY?

salaklar

New Member
I am trying to achieve the following:I have a single ORDER BY statement which could vary depending on the value stored in Column A.For example:if the Type is Member, sort by member last nameif the Type is Group, sort by the Group Nameboth in Ascending order.My best guess for the final statement would be:\[code\]SELECT * FROM table WHERE STATUS = 'Active' ORDER BY ((LNAME if TYPE = 'Member') OR (GROUPNAME if TYPE = 'Group')) ASC\[/code\]I know this is incorrect but cannot find information elsewhere. Any ideas?
 
Back
Top