Sort on Two Columns

From: Date: Mon, 15 Dec 2003 16:22:42 +0000
Subject: Sort on Two Columns
Groups: php.db 
Request: Send a blank email to php-db+get-32052@lists.php.net to get a copy of this message
I'm trying to sort a table on two columns but none of the options I've tried produces the right result (though the obvious works in mysql: order by caucuses.cbc, caucuses.state). I want to sort first by column caucuses.cbc (which distinguishes about 1/10 of the rows) and then by caucuses.state (which includes all rows). The CBC column designation ("B") should come first, with the rest of the CBC column blank. I'd actually like to sort by three columns (caucuses.cd is the third). Among others, I've tried: echo "<td><div align='center'><font size='3'><b>CBC <a href='108thfirst.php?sort_field=caucuses.cbc&sort_order=desc&sort_order=desc, sort_field=caucuses.state&sort_order=desc&sort_order=desc' target='_self'><font size='2'>Sort</a> </b></font></div></td>\n"; echo "<td><div align='center'><font size='3'><b>CBC <a href='108thfirst.php?sort_field=caucuses.cbc, caucuses.state&sort_order=asc' target='_self'><font size='2'>Sort</a> </b></font></div></td>\n";
      (This orders state first, cbc ordered at bottom by state;  reversing caucuses.cbc and caucuses.state gives state sort and cbc within state).
Thanks in advance. Ken

« previous php.db (#32052) next »