I'm working on a small script that will transfer order information from a newer database (for online orders) to an antiquated, custom database that they have 20+ years of information in and it only accepts tab delimited input (quite a pain) and can't handle multi-item SKUs (ie. each SKU is one item).

I've created a table (not shown) that relates the multi-item SKUs to the antiquated system's single SKUs - you can see below in rows 2 through 4 that there are three items in one (called "pcclean" online) that was originally one order line split into three rows (CL31, CL15, and CL13 - the old system's SKUs).

However, I'm having trouble splitting the price into three when generating this table. The prices change far too often to rely on stored values.

What I want to do is detect when Channel, Order, and Code are the same, and divide the "Total" in those rows by the number of rows that match that criteria.

PHP - was hoping I could just keep it to a single SELECT .... INTO OUTFILE '....txt' FIELDS TERMINATED BY '\\t' LINES TERMINATED BY '\\n' for simplicity's sake, but if there's no reasonable way to do that I'll do most of it in PHP.
–
rwhit85Oct 25 '12 at 12:13