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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:17:43+00:00 2026-06-09T05:17:43+00:00

I have this database design: **users_tbl** id username name **posts_tbl** id url users_id *FK

  • 0

I have this database design:

**users_tbl**
id
username
name

**posts_tbl**
id
url
users_id *FK REFERENCE to users table*

**posts_contents_tbl**
id
posts_id *FK REFERENCE to posts table
title
description
date
views
click
isDeleted

I’m using this query

SELECT a.name,a.username,c.*
FROM users_tbl a
LEFT JOIN posts_tbl b ON a.id = b.users_id
LEFT JOIN posts_contents_tbl c ON b.id = c.posts_id
ORDER BY c.id ASC

Why I try to run this query it gives me NULL results, sample output is like this
enter image description here

But when I try to remove the ORDER BY c.id ASC it gives me this output:
enter image description here

That’s not my expected result.

My expected result would be it will display the posts_contents_tbl in Ascending order at the same time it won’t show some null values. Some users in my database doesn’t have posts data in the posts_tbl so they should not show too.

How would I do that one? Your help would be greatly appreciated and rewarded!

Thanks!

PS: I already have thousands record in my database.

  • 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-09T05:17:45+00:00Added an answer on June 9, 2026 at 5:17 am

    In that case, you have to use INNER JOIN instead of LEFT JOIN because you only want users with posts to show. The reason why there are Null values is because the records are based on table users_tbl and you’ve mentioned that some of them have no post. Right?

    Try this:

    SELECT  a.name, 
            a.username,
            c.*
    FROM    users_tbl a 
                INNER JOIN posts_tbl b
                    ON a.id = b.users_id
                INNER JOIN  posts_contents_tbl c
                    ON b.id = c.posts_id
    ORDER BY    c.`date` DESC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following database design: Users Table: NetworkID, Name, BadgeNo, DepartmentCode Events Table:
I have a database design for a survey. I have a Table USERS with
This question applies to any database table design, where you would have system default
Let's say i have a database design like this: for the data: id |
I have this database structure, SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO; CREATE TABLE IF NOT EXISTS `announces` (
I have this enormous database : # # Dropping tables # DROP TABLE IF
So I have this game database, where I have several users with fields, id,
I have this line: @users = database['users'].find(:all).limit(10) it returns this object: <Mongo::Cursor:0x8759a858 namespace='app-development.users' @selector=:all
In mysql database i have this column called: Name: Date Type: datetime I have
my problem is , i have a database design from this link is my

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.