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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:36:33+00:00 2026-06-10T20:36:33+00:00

I have 3 tables as described below , table1 ‘ads’ id userid 1 47

  • 0

I have 3 tables as described below ,

table1 'ads'

 id     userid
 1       47
 2       47                    //ads.id  = adcat.adid
 3       45
 4       47

table2  'adcat'

  adid    catid
   1        1
   2        3
   3        3                 // adcat.catid  = categories.id
   4        3

 table3  'categories'

   id        name
    1        mathematic
    2        biolog
    3        leteratur
    4        chemi

What I want is to get categories.id from ads.id.

I have tried this

SELECT categories.id, ads.id 
FROM ads 
INNER JOIN adcat ON ads.id = adcat.adid 
INNER JOIN categories ON categories.id = adcat.catid 

But it does not come by the exact value.

obs : I don’t get any error just not exact value.
any help will be much appreciated.

  • 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-10T20:36:34+00:00Added an answer on June 10, 2026 at 8:36 pm

    Seems to be no reason to go in to categories table if adcat.catid = categories.id and that is the only value you need.

    SELECT ads.id,adcat.catid
    FROM ads
    INNER JOIN adcat
    ON ads.id=adcat.adid
    

    Use $row['catid'] with this query.

    If in the future you need more columns from categories then you will need a double join:

    SELECT categories.id *AS id*,ads.id *AS ads_id*
    FROM ads 
    INNER JOIN adcat ON ads.id = adcat.adid  
    INNER JOIN categories ON categories.id = adcat.catid
    

    Use $row['id'] with this query.

    See *AS id* and *AS ads_id* – remove the stars and you are giving the columns an ALIAS which is basically like a nickname, this can be handy in many cases but especially important in this case since the two columns both have the same names. So now you can call $row['id'] and get categories.id

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

Sidebar

Related Questions

I have two tables described below. What I need is a single query that
Suppose we have 4 tables as described below: Table 1: Element element_id [integer] (PK)
I have 3 tables listed below: Blog BlogArticle Article ---- ----------- ------- id id------blog_id
I have 3 tables - posts, friendships, and likes -- the important fields described
Briefly described, I have 2 tables that have 'equivalent' rows in each other. The
Let's say we have a time consuming query described below : (SELECT ... FROM
I have data in a mysql table in long / tall format (described below)
I have a polygon structure in an sql2005 db as described below. CREATE TABLE
I have trouble to figure out a php problem described below. I have one
I'm seeing basically the same issue described here I have a table that starts

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.