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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:32:43+00:00 2026-05-29T23:32:43+00:00

I have these tables: USERS: user_ID username password email data_registered POSTS: post_ID user_ID post_title

  • 0

I have these tables:

USERS:
user_ID
username
password
email
data_registered

POSTS:
post_ID
user_ID
post_title
post_content
post_data

CATEGORY:
cat_ID
post_ID
cat_title

Now I used this situation:

in USERS table I have:

(1, 'admin, '5hj63jhn120011', 'admin@gmail.com', '15.02.2012')

in POSTS table:

(1, 1, 'Hello', 'Content goes here', '15.02.2012')

in CATEGORY table:

(1, 1, 'web developing'), 
(2, 1, 'software programming'), 
(3, 1, 'web design')

So I have only 1 user, 1 post, and 3 categories. How to select them in one statement? I used this statement:

SELECT 
  p.post_title, 
  p.post_content, 
  u.username, 
  c.cat_title 
FROM 
  posts p 
  LEFT JOIN users u 
     ON p.user_ID = u.user_ID 
  LEFT JOIN category c 
     ON c.post_ID = p.post_ID

but this select 3 rows with 3 different categories. I’m still learning to make this JOIN queries properly so I would appreciate any help.

And after that, for example, I will have situation to select data from COMMENTS table as well, so this is going to be complicated. Just to mention this is comment table:

COMMENTS:
comment_ID
user_ID
post_ID
c_username
c_email
c_content

It’s gonna be tough to select this comments with user , post and category altogether. So one more question would be can I split this select queries and is this a good practice generaly (when developing with PHP) ?

  • 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-29T23:32:44+00:00Added an answer on May 29, 2026 at 11:32 pm

    Try:

    SELECT p.post_title, 
           p.post_content, 
           u.username, 
           group_concat(c.cat_title) categories
    FROM posts p 
    LEFT JOIN users u ON p.user_ID = u.user_ID 
    LEFT JOIN category c ON c.post_ID = p.post_ID
    group by p.post_id
    

    – if you want to see all the categories for a single post in the same row.

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

Sidebar

Related Questions

I'm on a pseudo-social app. We have 3 tables: Users: _id_, username, password, email
i have one signup form where i have three field username,password and email address
I have users table. There are three other tables: developers, managers, testers. All of
Requirements : I have a table of several thousand questions. Users can view these
I have these tables: customer -------- customer_id int name varchar(255) order ----- order_id int
I have these tables: Projects(projectID, CreatedByID) Employees(empID,depID) Departments(depID,OfficeID) Offices(officeID) CreatedByID is a foreign key
Suppose you have these tables: Table Name: Salesman Fields: S_ID(Primary Key), Name Table Name:
I have these 3 tables + data: items : itemId, itemName data: 1, my
If I have these two tables: <table> <tr> <td>Small Length Content</td> </tr> </table> <table>
I have some tables. These tables all have one column in common called 'classified_id':

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.