Results 1 to 4 of 4

Thread: Access/SQL: Condensing multiple rows into one row

  1. #1
    Join Date
    Oct 2005
    Posts
    5

    Access: Condensing multiple rows into one row

    I have a table with employees and their email addresses. Unfortunately for my company, when the info was entered, nobody bothered to check if the same person has multiple email addresses.

    Now, I have 3 rows with John Doe's email addresses, 2 rows for Sam Johnson, 2 rows for myself, etc..

    Employee_id Name Email
    23 John Doe [email protected]
    23 John Doe [email protected]
    23 John Doe [email protected]
    1 Shane Holmes [email protected]
    1 Shane Holmes [email protected]
    34 Sam Johnson [email protected]
    34 Sam Johnson [email protected]

    I want to condense the multiple rows so I have one row per employee but with all of the email addresses:

    Employee_id Name Email
    23 John Doe [email protected], [email protected], [email protected]
    1 Shane Holmes [email protected], [email protected]
    34 Sam Johnson [email protected], [email protected]

    My friend said we should run a query and do a query of a query. Problem is, I'm still getting multiple rows per employee. Can anybody suggest a fix? Maybe I'm joining the queries wrong or maybe I don't need a query at all?
    Last edited by shaneholmes; 10-19-2005 at 11:16 AM.

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    Then the table is not in first normal form.

  3. #3
    Join Date
    Oct 2005
    Posts
    5
    How can I resolve this problem? According to another friend of mine, the only way to concatenate would be to write code.

    I dont know enough about databases and even less about code to get the job done.

  4. #4
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    You have to write a procedure with cursor to loop through all email addresses for the same individual and update one row and delete rest.

    You can't do it with one simple T-SQL Statement

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •