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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:53:04+00:00 2026-06-18T12:53:04+00:00

I have two tables: users and posts. The posts table has a ‘post’ column

  • 0

I have two tables: “users” and “posts.” The posts table has a ‘post’ column and a ‘poster_id’ column. I’m working on a PHP page that shows the latest posts by everyone, like this:

SELECT * FROM posts WHERE id < '$whatever' LIMIT 10

This way, I can print each result like this:

id: 43, poster_id:'4', post: hello, world
id: 44, poster_id:'4', post: hello, ward
id: 45, poster_id:'5', post: oh hi!
etc...

Instead of the id, I would like to display the NAME of the poster (there’s a column for it in the ‘users’ table)

I’ve tried the following:

SELECT * 
FROM posts 
WHERE id < '$whatever' 
       INNER JOIN users 
           ON posts.poster_id = users.id LIMIT 10

Is this the correct type of join for this task? Before learning about joins, I would query the users table for each post result. The result should end up looking similar to this:

id: 43, poster_id:'4', name:'foo', post: hello, world
id: 44, poster_id:'4', name:'foo', post: hello, ward
id: 45, poster_id:'5', name:'fee', post: oh hi!
etc...

Thanks for helping in advance.

  • 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-18T12:53:05+00:00Added an answer on June 18, 2026 at 12:53 pm

    WHERE clause must come after the FROM clause.

    SELECT  posts.*, users.*   // select your desired columns
    FROM    posts 
            INNER JOIN users ON posts.poster_id = users.id 
    WHERE   id < '$whatever'
    LIMIT   10
    

    the SQL Order of Operation is as follows:

    • FROM clause
    • WHERE clause
    • GROUP BY clause
    • HAVING clause
    • SELECT clause
    • ORDER BY clause

    UPDATE 1

    For those column names that exists on both tables, add an ALIAS on them so it can be uniquely identified. example,

    SELECT  post.colName as PostCol, 
            users.colName as UserCol, ....
    FROM ....
    

    on the example above, both tables has column name colName. In order to get them both, you need to add alias on them so in your front end, use PostCol and UserCol to get their values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two column table friends table where it has a recode of users
We have two tables - Tasks and TasksUsers (users assigned to task). Task has
I have two tables users registered_members I want to confirm values from user table
I have a Database with the following two tables, USERS, POSTS I am looking
I have two items, users and posts, and a join table linking them together.
im using mysql, these are two tables i have: posts {id, user_id, post, date}
In my application I have two tables: Users and Profiles. A user has a
I have two tables: Users: ID, first_name, last_name Networks: user_id, friend_id, status I want
I have two tables- users and language with a foreign key link of their
hope someone can help. I have two tables: Users -UserID -UserName UsersType -UserTypeID -UserID

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.