MySQL Forums
Forum List  »  Newbie

Amazon alike collaborative filtering
Posted by: sumerianx sumerianx
Date: November 09, 2007 08:48PM

Hi, i am trying to create a very basic version of
"people who bought this also bought that".

so i have a table1 and table2, they look like this
table1 is all the products with details.
table2 is who bought what. the product_id in table2 is
the table1's id for the product.

id | name
1 | apple
2 | orange
3 | banana
4 | milk
5 | chocolate

user | product_id
john | 4
mike | 3
mike | 1
john | 2
john | 5

so lets say i wanna know " what other products were purchased by those who purchased milk ".

what do i do. i need to print out the names of the products excluding the milk itself.

i imagine the query has to connect table1 and table2 then find all the users who purchased milk in table2 and then find all the products purchased by those users and then connect those products with table1 to get their names.

can all this be done in just 1 MySQL query?


Edited 2 time(s). Last edit at 11/09/2007 09:49PM by sumerianx sumerianx.

Options: ReplyQuote

Written By
Amazon alike collaborative filtering
November 09, 2007 08:48PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.