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

  • SEARCH
  • Home
  • 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 7063911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:46:12+00:00 2026-05-28T04:46:12+00:00

I have a list of comments. For every comment, there might be subcomments (kind

  • 0

I have a list of comments. For every comment, there might be subcomments (kind of like the comments to answers in Stack Overflow).

What I am not sure how to do, is query for all of that in one query. I have this so far:

select 
  problem_id , suggester_id , solution , suggested_solution_id , 
  DAYOFMONTH(solution_date) , DAYNAME(solution_date) , YEAR(solution_date) , 
  MONTH(solution_date) , first_name , last_name , email , 
  small_thumb , mid_thumb , solution_name , suggested_solution_comment.comment 
from suggested_solutions 
left join users 
  on suggested_solutions.suggester_id = users.user_id 
left join member_photo 
  on suggested_solutions.suggester_id = member_photo.member_id 
left join suggested_solution_discussion 
  on suggested_solutions.suggested_solution_id = suggested_solution_discussion.suggested_solution_id 
left join users 
  on suggested_solution_discussion.commenter_id = users.user_id 
left join member_photo 
  on suggested_solution_discussion.suggester_id = member_photo.member_id 
where problem_id = id;

And suggested_solution_discussion is the subcomments of comments. So I end up joining the suggested_solution table with the users table, and in order to display who made the sub-comments, I end up having to join for suggested_solution_discussion table with the users table to.

And I get this error:

ERROR 1066 (42000): Not unique table/alias: 'users'

What would be the right way to make this query?

  • 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-05-28T04:46:12+00:00Added an answer on May 28, 2026 at 4:46 am

    You have joined to the users table twice and need to provide an alias to each so that they can be distinguished

    ...
    left join users as users_1 on suggested_solutions.suggester_id = users_1.user_id  
    ...
    left join users as users_2 on suggested_solution_discussion.commenter_id = users_2.user_id  
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings, I have a list of user comments on a page, with a next
We have a SharePoint list setup with history enabled so the Comments field keeps
I have a large threaded comment list. When a person replies the author gets
you have some info on an item and you got a list of comment
i have list of images and on mouse over there is option box shows
I have list of comments in one array. Can I use update_all on array
I have List I want to sort Desc by Priority, which is int and
i have list of rows that user select and i want to delete them,
I have list of words. I type in a word misspelled. Can I query
I have list of files which contain particular patterns, but those files have been

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.