I want my subquery results (multi rows) return as a singale row in my query. For example.

SELECT u.url, (SELECT c.categoryid FROM category c 
WHERE c.categoryid = u.categoryid) FROM url u

If url contains multiple categories, subquery will return multiple rows as following
P.S Subquery return multiple rows is not supported in most of the database but PostgreSQL

url | categoryid
---------------------
1   |  1
1   |  2
2   |  1

Result i wanted is as following

url | categoryid
---------------------
1   |  1,2
2   |  1

I’m not sure how easy it can achieve in others database like oracle or mysql, however PostgreSQL provided Array data type, using array it’s very easy to get what i want. I have to changed my query to

SELECT u.url, (SELECT array(SELECT c.categoryid FROM category c 
WHERE c.categoryid = u.categoryid))AS categoryid FROM url u

Result ~

url | categoryid
---------------------
1   |  {1,2}
2   |  1

Done ~ PostgreSQL Array Rock ~

Any Java questions or problems? please post at this JavaNullPointer.com forum, see you there ~