> except that I just added the ORDER BY clause onto each SELECT segment, > and now I get this error: > query failed: Incorrect usage of UNION and ORDER BY > > How can I order the results while still doing the UNION ALLs? You should only need one ORDER BY clause at the end of the whole query: (SELECT...) UNION ALL (SELECT...) UNION ALL (SELECT...) ORDER BY... I'm not sure if this syntax is portable to other SQL-based DBMSes, though. I'm certain that one system we use at work doesn't support it, but it's kind of a dinosaur so I don't like to draw too many conclusions from what it doesn't support. Ben -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php