Does anyone have a clever way that I can sort on two fields? Let me
explain...I need the sort to be by the "uid" field (see below), but also
have the "parent" field taken into consideration:

Here's a sample of what I get now:

+-------+-----------+--------+
| uid   | duplicate | parent |
+-------+-----------+--------+
| 12880 |         1 |  12878 |
| 12879 |         0 |   NULL |
| 12878 |         0 |   NULL |
| 12877 |         0 |   NULL |
| 12840 |         0 |   NULL |
| 11616 |         0 |   NULL |
| 10871 |         0 |   NULL |
|  7696 |         0 |   NULL |
|  5770 |         0 |   NULL |
+-------+-----------+--------+

Here's what I want:

+-------+-----------+--------+
| uid   | duplicate | parent |
+-------+-----------+--------+
| 12879 |         0 |   NULL |
| 12878 |         0 |   NULL |
| 12880 |         1 |  12878 |
| 12877 |         0 |   NULL |
| 12840 |         0 |   NULL |
| 11616 |         0 |   NULL |
| 10871 |         0 |   NULL |
|  7696 |         0 |   NULL |
|  5770 |         0 |   NULL |
+-------+-----------+--------+

Note that "uid" 12880 is now AFTER 12878, which is its parent. I know in PHP
I can easily do this. Just wondering if I can get it out of MySQL directly,
rather than writing PHP code to do it. This is MySQL 5.0, by the way.

Thanks,

Rob



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to