File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Problem in fetching records Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Problem in fetching records" Watch "Problem in fetching records" New topic

Problem in fetching records

Akash Abrol

Joined: Jan 30, 2006
Posts: 9
I have a table with two columns: loginID and PhoneNo. There can be many phone no's associated with one login ID and there will be one row each for a loginID,Phone No pair....

Now, if i select all the records from the table, there may be different rows with same loginID.

Is there any possible SQL query that gives me records as:

LoginID, {A comma separated list of all phone no's}

So that there is only one row for each loginID.

Sathya Prabhu

Joined: Mar 10, 2006
Posts: 12

There is no SQL query that can retrieve directly the records which you are asking for.

One alternative is using an ORDER BY clause.But one good option will be normalising ur tables!!!

I agree. Here's the link:
subject: Problem in fetching records
jQuery in Action, 3rd edition