Hello,
I am trying to use GROUP BY and ORDER BY in the same query
table:
col_1-letters
col_2-numbers
row1 A 5
row2 A 6
row3 A 4
row4 B 2
row5 B 1
row6 B 3
$q = mysql_query("SELECT col_1 FROM table GROUP BY col_1");
while($row = mysql_fetch_array($q))
{
extract($row);
echo the results here
}
Result:
table row 1 - A
table row 2 - B
$q = mysql_query("SELECT col_2 FROM table ORDER BY col_2 desc");
while($row = mysql_fetch_array($q))
{
extract($row);
echo the results here
}
Result:
table row 1- 6
table row 2- 5
table row 3- 4
table row 4- 3
table row 5- 2
table row 6- 1
What query will produce this?
table row 1- A 6
table row 2- B 3
Thanks