Mysql query: Number of mutual friends

Hi,

I need get the count of mutual friends between user 1 and 3 and here is example of my friends table:

[sql]INSERT INTO tbl_contatcs (id, u_id, f_id, status) VALUES

(1, 1, 2, 10),

(2, 1, 3, 10),

(3, 1, 4, 10),

(4, 3, 1, 10),

(5, 3, 2, 10),

(6, 4, 3, 10),

(7, 4, 5, 10),

(8, 5, 2, 10),

(9, 5, 6, 10);[/sql]

Here I want to get the e.g mutual friends of user 1 and user 3 and their status is 10(friends);

The out put I need is,

[sql](1, 1, 2, 10),

(3, 1, 4, 10),

or

(5, 3, 2, 10),

(6, 4, 3, 10),[/sql]

The count of mutual friend is 2 and mutual friends are 2 and 4… Please any one help me to write the sql query.

My link

Try This.