 | I have a single mysql table that has sales records. Each record is for one of perhaps several items in a transaction, i.e. a sale of several items will have several lines in the dataset, each with the same transaction number.
What I want to do is 1)find the widget that is most popular in sales, then 2)get those transactions that have that widget, and then 3)look at those transactions to see what else is on them; see if these's a second item that tends to sell along with that most popular seller.
I'm sure this is a pretty common query concept, but I'm unclear on the logic. I have only one dateset. Is this a case for a self-joined table? or could a nested query do this? I can get up to 2)the transaction list, but don't know how to go back in with that in the same query to see what's on them (3),short of doing a second query on one transaction at a time.
The data is out of an old application. I run a report that is little more than a dump-as-.csv and then LOAD DATA INFILE that into a mysql table on my desktop. I could use any hints, ideas, pointers or tutorials, And thanks.
r
|
|