Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8610153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:03:41+00:00 2026-06-12T04:03:41+00:00

I’ve made one table for all comments on a social network site: comment Also,

  • 0

I’ve made one table for all comments on a social network site: comment

Also, I’ve one table for all comments assigned to one comment: comment_assign

So, I built a function comment() to implent it easily in each section type (images, userpage, groups, etc). In case of $_GET[‘s’]==user, I want to have wallposts as well as comments on these wallposts. All stored in ‘comment’.

I’ve got this scheme to display this:
1. sql query to get the comments
2. html output
3. another sql query inside this html output to get specified assigned comments of a comment (wallpost in this case)

Now the problem is that my first query displays all comments. Also comments that are supposed to be subcomments. So my question is, if there’s any way to specify in this first query, when I get all my comments, to say: Look in comment_assign if this comment_id is available. And if it is, don’t display this comment, because it’s a subcomment (that I’ll display in mentioned step 3).

Maybe this whole structure may be changed? I would appreciate any suggestions. Even hard to realized ones, but which would be the most efficient.


Table structure:

comment

id, uid, nid, site, text, date

comment_assign

comment_id, assign_id


First SQL Query example, which doesnt work to avoid displaying all the comments (also assigned ones). See the last line:

SELECT *    
FROM `comments` AS c
LEFT JOIN `comment_assign` AS ca ON ca.`comment_id` = c.`id` 
LEFT JOIN `users` AS u ON c.`uid` = u.`id` 

WHERE c.`nid`='".$nid."' 
AND c.`site`='".$_GET['s']."' 
AND ca.`comment_id` != c.`id`
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:03:42+00:00Added an answer on June 12, 2026 at 4:03 am

    If I understand you correctly, you select all the comments from the comment table. You then want to check to see if comment.id is present in comment_assign.comment_id. If it is present, it is a sub-comment. Is that correct?

    You can do it two ways – the clean way is to add another field to the comment table and put assign_id there, since each comment can only be associated with another comment, or is a top-level comment (*assign_id is NULL*).

    Alternatively, you could LEFT JOIN both tables. Every row where assign_id is NULL, is a wall comment, every row where it has a value means it is assigned as a sub-comment. i.e.

    SELECT id, uid, site, text, date
    FROM comment
    LEFT JOIN comment_assign ON (comment.id = comment_assign.comment_id)
    WHERE comment_assign.assign_id IS NULL;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I need a function that will clean a strings' special characters. I do NOT
I want to construct a data frame in an Rcpp function, but when I
I'm parsing an XML file, the creators of it stuck in a bunch social
I'm making a simple page using Google Maps API 3. My first. One marker

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.