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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:09:46+00:00 2026-06-01T00:09:46+00:00

I need help regarding JOIN tables to get category name & author name from

  • 0

I need help regarding JOIN tables to get category name & author name from other tables.

for articles site I have Three Tables

  • articles
  • categories
  • users

Articles Table structure :

id
title
slug
content
category
author
date

I save category ID & user ID in articles table with each article

While Displaying Articles for a category I use this:
(just some draft idea not full code)

localhost/testsite/category.php?cat=category-slug

$catslug = ($_GET["cat"]);

//GET CAT ID from category table from slug

$qry = "SELECT * from category WHERE slug='$catslug';
$res = mysql_query($qry) or die("Error in Query");
$ans = mysql_fetch_array($res);
$cid = $ans['id'];
$catname = $ans['title'];

<h2><?php echo $catname; ?></h2>

//after getting cat-id query to get article of that ID

$aqry = select * from article where category=$cid ORDER BY date";
$ares = mysql_query($aqry) or die("Error in Query");
$aans = mysql_fetch_array($ares))
$aid = $aans['author'];

//then another query to get author name from users
select username from users where id=$aid

I m learning PHP & not much familiar with JOIN statement & combining queries
need help/suggestions hw can I achieve same with JOIN tables instead of different queries to get catname and author name from tables.

Thanks

  • 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-01T00:09:48+00:00Added an answer on June 1, 2026 at 12:09 am

    This should do what you want

    SELECT distinct c.title, U.Username
    from category C join article A on A.category=C.id
    join users U on U.id=A.author
    WHERE C.slug= :catslug
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a help regarding an issue in android... I have an application with
i need help regarding dokuwiki i want to remove versioning from wiki. any tip
I need some help regarding Visual Studio solution and project organization. I have a
i need help regarding the save menu item i have in my menu bar.
I need some help regarding .htaccess rewrite rule. One of my page have combination
I need some help regarding interprocess communication. I have an Application A and Application
need help regarding USSD Gateway. I have to develop an app, which will directly
I need help regarding array insertion into mysql table. I have an array when
I need help regarding DDA algorithm , i'm confused by the tutorial which i
I need some help regarding algorithm for randomness. So Problem is. There are 50

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.