Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2003

    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.


  2. #2
    Join Date
    Mar 2003
    Atlanta, GA

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts