How to combine two data rows into one

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • almaroc
    New Member
    • Nov 2011
    • 48

    How to combine two data rows into one

    I am trying to find a way to combine two rows of data into one. the data is as follows
    Fields: Company Phone
    XYZ 801.222.3333
    XYZ 712.444.5555
    I want to achieve the following result:

    Fields: Company Phone1 Phone2
    XYZ 801.222.3333 712.444.5555
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Why would you want to do that? You would be denormalizing the data.

    Comment

    • almaroc
      New Member
      • Nov 2011
      • 48

      #3
      this data is used for an automated dialer. the way the program is set up. it require the data to be formatted in one row to be mapped correctly. the original table were remain the same. however i would a query that generate the one row per company

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        And if a company has more than 2 phones?

        Comment

        • almaroc
          New Member
          • Nov 2011
          • 48

          #5
          i would like to do the same if the company has more than two phone numbers. if i figure out how to solve the problem with two numbers. I think i might be able to make it work regardless of the number of phone numbers.

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            First you need to number the rows breaking on the company. Then you pivot your data on that new field. Unfortunately, MySQL doesn't have row number functionality nor does it have pivot syntax. But fortunately, you can achieve a similar result using variables and case statements / self joins.

            Comment

            • almaroc
              New Member
              • Nov 2011
              • 48

              #7
              Thanks. I will try that in access and see what i can figure out. I appreciate your help

              Comment

              Working...