Thursday, 12 September 2013

mysql ORDER BY specified order

mysql ORDER BY specified order

simplified:
$q = mysql_query("SELECT * FROM mytable ORDER BY category") or
die(mysql_error());
while($row = mysql_fetch_array($q)) {
$cat = $row['category'];
echo $cat."<br />";
}
mytable holds Apple, Banana, Citrus
I want the result to display in a specific order, like Banana, Apple, Citrus.
How do I make my query?

No comments:

Post a Comment