I have this problem:
given N users subscribed to a website, if the user who visits the page is logged, show a list of suggestions on the basis of friends in common between X and Y.
I asked to my information technology's professor how to solve it, but he only knows SQL and i need MySQL code (I use PhpMyAdmin).
How can I translate this SQL code into MySQL code?
Code for "QUALIAMICI" (it tells me what are the friends of X (Y is a list of id) )
CREATE PROCEDURE QUALIAMICI ( X integer ) RETURNS ( Y integer ) AS
BEGIN SUSPEND; END^
ALTER PROCEDURE QUALIAMICI ( X integer ) RETURNS ( Y integer ) AS
begin
for
select idDestinatario from amicizie where idmittente=:x
union
select idMittente from amicizie where iddestinatario=:x
into :y
do suspend;
end^
Code for "AMICI_COMUNI" (it tells me the friends in common between X and Y)
CREATE PROCEDURE AMICI_COMUNI ( X integer, Y integer ) AS
BEGIN SUSPEND; END^
ALTER PROCEDURE AMICI_COMUNI ( X integer, Y integer ) AS
begin
insert into Uno (id_amico) select * from QUALIAMICI(:x);
insert into Due (id_amico) select * from QUALIAMICI(:y);
insert into Tre (id_amico) select * from Uno where id_amico in (select id_amico from due);
end^
How can I translate this into MySQL? I know very little about MySQL, so I'd like that you explained what suggested.
P.S.: can you understand the algorithm, even if I haven't translated the variables into english? P.P.S.: i'm sorry for bad english, I'm italian :S