This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Problem in fetching records Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
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
Similar Threads
memory usage with EntityBeans
Tables in JSP Report
Populating values to feilds from the Table
Printing records in two or more columns
Deleting Duplicate Rows.