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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:20:58+00:00 2026-05-13T15:20:58+00:00

I am very new to mysql and databases, so I need help here… How

  • 0

I am very new to mysql and databases, so I need help here…

How should I use JOIN to fetch a record from the tables below, when the only given variable is the ad_id?

category and category options are filled in manually i.e. the users may not alter them. So they are only reference tables, but I am not sure this is how I should do it…
I have 6 tables:

category:
cat_id (PK)
cat_name

category_options:
option_id (PK)
cat_id (FK)
option_name

option_value:
value_id (PK) (AI) // I think this should have Auto Increment
option_id (FK)
classified_id (FK)
value

classified: (THIS IS THE MAIN TABLE YOU COULD SAY)
classified_id (PK) (AI)
ad_id
cat_id
headline
description

area: // I am thinking about moving these fields over to the posters table, right?
area_id (PK)
classified_id (FK)
area
description

Here is how I insert a classified into the tables:

mysql_query("INSERT INTO classified (ad_id, cat_id, headline, description) VALUES ('$ad_id', $cat_id, '$headline', '$description')");
$last_classified_id=mysql_insert_id();

mysql_query("INSERT INTO poster (classified_id, name, email, tel) VALUES ($last_classified_id, '$name', '$email', '$tel')");

mysql_query("INSERT INTO area (classified_id, area, community) VALUES ($last_classified_id, '$area', '$community')");

I am new to JOIN!

Every category has sub options (CARS -> color) and every option has a value.
I want to, only by having the ad_id, select all this information.

How can I do so?

And should I merge the area and posters table?
Also, please take a careful look at my db, and tell me if there is anything I might have missed…

This is really out of my knowledge-base so detailed explanations are appreciated!

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-05-13T15:20:58+00:00Added an answer on May 13, 2026 at 3:20 pm

    It looks like you have two fields that could be the primary key in classified: classified_id and ad_id. Then you have two other tables, poster and area, that have a one-to-one correlation with classified. If this is the case, you could put all the fields in classified.

    A query to join the tables in your insert statements would like like this:

    select
        classified.ad_id,
        classified.classified_id,
        classified.headline,
        classified.description AS classified_description,
        poster.name,
        poster.email,
        poster.tel,
        area.area,
        area.description AS area_description from
        classified inner join
        poster
        on
            classified.ad_id = poster.classified_id inner join
        area
        on
            classified.classified_id where
        classified.ad_id = 123
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 320k
  • Answers 320k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can try to run the CD/DVD through vLite to… May 14, 2026 at 12:17 am
  • Editorial Team
    Editorial Team added an answer In the case of the openDocument() command, you could just… May 14, 2026 at 12:17 am
  • Editorial Team
    Editorial Team added an answer Nope, if you wan't to customize your marker, you will… May 14, 2026 at 12:17 am

Related Questions

I have inherited a broad, ill-designed web portfolio at my job. Most pages are
I'm learning Ruby on Rails and doing the contactlist thing, 20 minute blog and
Hey there guys and gals. I'm very new to php and am following various
On a page I am working on, I have several distinct pieces of PHP,
I am creating a tool with which to edit web pages within a CMS.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.