I have 2 columns in my database. One is named "name01" and the other is named "name02". This database displays friends on my app. When I go to my friends list on the app I want all my friends displayed by name in asc order. The problem is users names could be in "name01" or "name02" depending on who sent the friend request first. How would you "order by" both name01 & name02 at the same time? I have tried doing it with a comma (ORDER BY name01, name02) but it orders one first and then the other so the names aren't all in alphabetical order.
$sql = mysql_query("SELECT * FROM friends WHERE id01 = '$id' AND status01 = '1' OR id02 = '$id' AND status02 = '1' **ORDER BY name01, name02** Limit 500");
Above will order name01 separately from name02.