Database SQL Query

You are required to design a social networking site. Set of all those people who are friend of friends your friends would be consider to be in your network. Write a SQL query to print Number of people in your network.
You need to create a profile of each user and store his/her photographs. How would you go about doing the same using database?

Questions by mohitkumarsingh

Showing Answers 1 - 1 of 1 Answers

gudluck

  • Jul 11th, 2009
 

Answer for ist part of the question:

Create 2 tables mapidandnames and friends

Table:mapidandnames

id    name
--------------
  1    a
  2    b
  3    c


Table:friends

id   friendid
-------------
 1     2
 1     3
 2     3


Query: select name from mapidandnames where id in (select friendid from friends where id=(select id from mapidandnames where name='a'));

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions