Jump to content

MySQL Duplicate Rows


thegladiator

Recommended Posts

I have an excel spreadsheet that I can enter into a table and manipulate far faster in MySQL. The issue is that the rows are Duplicated. The structure is shown below.

 

Part Number | Description | Qty | Cost | OEM Resale

ABC            | Switch       | 1     | 1.00 | 3.5

ABC            | Switch       |25    | 1.00 | 2.75

 

Desired Result

Part Number | Description | Qty1 | Cost1 | OEM Resale1 | Qty2 | Cost2| Resale2

 

I would like to have them in separate columns. I'm using phpmyadmin to write my querys. Is this at all possible? The best i've seen is the concat function which once i get past description would put all remaining data into one field that has been comma separated. I could do that and transfer back to excel. 

 

I ask as the file that I'm using is 30K+ rows and the coworker i'm setting this up for gets this file in the same format to evaluate about 5 times a year

 

thanks

 

c

Link to comment
https://forums.phpfreaks.com/topic/286322-mysql-duplicate-rows/
Share on other sites

databases are relational, so use them. You have duplication that you need to normalise. Part number and descirption could be moved into a parts table. then you could have an orders table. so would look like:

// parts table

id | part_number | part_description
 1     ABC           Switch

//orders table:

id | part_id | Qty | Cost | OEM_Resale
 1      1       1     1.00   3.5
 2      1       25    1.00   2.75

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.