ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button
  SQL Subqueries
Subject:   How to sort a subquery?
Date:   2006-01-26 13:06:12
From:   cyberlogi

I have a query with a subquery that looks like the following

SELECT name FROM userTable WHERE id = ANY ( SELECT id FROM otherTable WHERE otherId = X)

OtherTable is a table where id can be connected to many otherIds. And userTable's primary key is id and contains the name of the user among other relevant information. I need to sort this query according the lastUpdate time in otherTable. I have tried adding ORDER BY to the subquery, with many different combination, but it always spits out the data in the same order.

Please advise what I can do differenty in my query to ORDER this data. Thanks.