Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in fetching records

 
Akash Abrol
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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.

Regards,
Akash.
 
Sathya Prabhu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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!!!

Sathya
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic