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 7435509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:05:13+00:00 2026-05-29T10:05:13+00:00

Database Scheme : http://pastebin.com/aPXk1rMf I’m want to select post owner’s uName and comment owner’s

  • 0

Database Scheme:
http://pastebin.com/aPXk1rMf

I’m want to select “post owner’s uName” and “comment owner’s uName” from “comments” table (i.e. I think I need cOwnerID>uName and pID>uID>uName) so that I can log some activities right after a comment is posted.
I tried to use MySQL joins in order to achieve that but I couldn’t; so here’s what I tried in vain.

$result = dbquery("INSERT INTO comments VALUES ('','$pID','$ownerID','$cmnt')"); // inserting a comment

$lastID = mysql_insert_id();

$res = dbquery("SELECT
                users.username AS username
            FROM `comments`
            LEFT JOIN `users` on comments.cOwnerID = users.uID
            WHERE (cID='$lastID')");
  • 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-29T10:05:14+00:00Added an answer on May 29, 2026 at 10:05 am

    I think you have to use aliases for table users, because, actually, you will have two joins on this table : one for the post author and another for the comment’s author.

    Try something like this :

                SELECT
                    commentAuthor.username AS commentauthor_username,
                    postAuthor.username AS postauthor_username
                FROM `comments`
                LEFT JOIN `users` AS commentAuthor on comments.cOwnerID = commentAuthor.uID
                LEFT JOIN `posts` on posts.pId = comments.pID
                LEFT JOIN `users` AS postAuthor on posts.uID = postAuthor.uID
                WHERE (cID='$lastID')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my database database schema http://slashdir.com/php/blogg/images/bloggdb.png What i want to do, is, for
I have this database scheme: http://i54.tinypic.com/k9hzc.png As you can see, I have three columns
For example: http://stackoverflow.com/questions/396164/exposing-database-ids-security-risk and http://stackoverflow.com/questions/396164/blah-blah loads the same question. (I guess this is DB
I have the following database schema: http://lh4.ggpht.com/_SDci0Pf3tzU/SdM3XnAmmxI/AAAAAAAAEps/Ie3xW3ZVNfQ/s400/styleerror.png And this is my mapping file: <?xml
Lets imagine I have the same database schema as here: http://www.databaseanswers.org/data_models/driving_school/index.htm If a customer
I am looking for help with the database scheme, not the actual cloud itself.
I have 3 Oracle database instances with the same data and scheme that I
For our SQL Server database, we're using a versioning scheme to track schema updates.
What is a good, simple encryption scheme for protecting passwords in a database? I
I’m having a problem getting the data from my database which I created to

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.