mysql - Select all post and its comments for a specific user -


I have a general situation, I want to choose all posts and comments for a specific user. For example:

  1) Post: 1 (post id), some title, some text 2 (post id), some title, some text comments: 1, 1 (post id), comment comment, comment Text, User ID (1 - 2, 1 (Post ID), CommentTitle, CommentTest, UserID (1 - from second table) 3, 2 (Post ID), CommentTitle, CommentTest, UserID (2 - from second table) 4, 2 ( Post id), comment title, comment text, UserId (2 - from second table)   

for example , I want to select the first post in a result set and his comments in other results as determined by the User ID. In short, I would like to select all the comments and comments made by the user. Can anyone help me? And I was thinking of making SP as a post ID parameter, but I had problems.

This selects All posts are Select Post from where in Post ID (select PostID from comments where URIID = 1);

Select all these comments and comments:

  Postp From SELECT *, comments ASC WHERE C.PostID = P.PostID and C.UserID C. 1 group by COMMENT id;   

(not tested, but should work)

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -