var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: People who have bought item X, also bought items W,R,Y,Z
I need your help...
I'm trying to build an application that will tell me what items have been sold along with an item we will call "X".
I have a huge list of tickets with the following cells: ticket number, item code, amount of items sold, and date (which won't be used)
What I need is that when I select item 203923 e.g., the query will give me a list of 10 other items (in order of sales) which have sold along with the first one.
I would really appreciate anyone's help.
Re: People who have bought item X, also bought items W,R,Y,Z
Let's call the table Sales.
Let's just look at ticketid and itemid. I'll assume that all items bought together are on the same ticketid.
Then, SELECT ticketid FROM sales WHERE itemid="12345" gives you all the tickets where item 12345 was purchased.
SELECT itemid FROM sales WHERE ticketid IN (SELECT ticketid FROM sales WHERE itemid="12345") will give you a list of all the items that are on tickets along with item 12345
I haven't gone through the trouble of trying this all out, but it should give you a good start.