Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Complex sql sub query
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

1 Posts

Posted - 09/28/2012 :  19:19:13  Show Profile  Reply with Quote

I am building a small social network for my department.

I have the homepage as a place where you can make comments and your friends can comment on it.

I have 4 tables ...allposts_tb, friendship_tb,response_tb and signup_tb..

The allposts_tb collect the updates and post made by people it has the following columns (all_id(PK),name,comment,time)

The friendship_tb as the columns (friend_id(Pk),myname,newfriend,status)

The response_tb as columns(id(Pk),name,response,all_id(Fk),time)

The signup_tb as columns (signup_id,lastname,firstname,email,password,country,profilepicture)

I can display comments made by people easily using the sql query below

SELECT allposts_tb.all_id,,allposts_tb.comment, allposts_tb.time,
FROM allposts_tb,friendship_tb,signup_tb
WHERE = friendship_tb.newfriend
and friendship_tb.myname=colname and
ORDER BY allposts_tb.all_id DESC


Well am having problems displaying responses made by people on a particular comment right below the comment...just like replicating facebook's page.Immediately you say something,it should be displayed right below the comment... I know am meant to use a sub query. right inside the query i gave you guys..have read a lot of web pages but cant get it to work...please help me...

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 10/01/2012 :  11:06:40  Show Profile  Reply with Quote
can you show some sample data from tables and explain how you want output to be displayed?

SQL Server MVP

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000