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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:31:17+00:00 2026-05-31T16:31:17+00:00

My Current Database Structure: `images` `tags` `images_tags` ________________ ______________ ________________________ | id | title

  • 0

My Current Database Structure:

     `images`            `tags`             `images_tags`
 ________________    ______________    ________________________
| id | title     |  | id | name    |  | id | image_id | tag_id |
|----|-----------|  |----|---------|  |----|----------|--------|
|  1 | Ivysaur   |  |  1 | fire    |  |  1 |     2    |    1   | Charizard: fire
|  2 | Charizard |  |  2 | flying  |  |  2 |     2    |    2   | Charizard: flying
|  3 | Squirtle  |  |  3 | water   |  |  3 |     1    |    4   |   Ivysaur: grass
|  4 | Pidgey    |  |  4 | grass   |  |  4 |     4    |    2   |    Pidgey: flying
 ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

I want to output tags with their respective values (name).

if ($_GET["pokemon"] == "2") {
    // output Charizard's tags: fire, flying
}

But I am struggling at coming up with a proper query to do this. INNER JOIN is unfamiliar to me and an explanation on how it works would be very helpful.

  • 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-31T16:31:18+00:00Added an answer on May 31, 2026 at 4:31 pm

    Pokemon. LOL! xD

    To output tags:

    SELECT t.id, t.name
    FROM tags AS t 
       INNER JOIN images_tags AS r ON r.tag_id =t.id
       INNER JOIN images AS i ON r.image_id =i.id
    WHERE i.id ='2'
    
    1. Select from the tags table and alias it as “t”
    2. Join the third table (association) with the alias “r” and with r.tag_id =t.id
    3. Join the images table with the alias “i” and with r.image_id =i.id
    4. Finally sets the filter: i.id =’2′ (but will be mysql_real_escape_string($_GET['pokemon']) since you do not want SQL injection)

    Now a shortcut:

    if(isset($_GET['pokemon')) {
        $image_id = (int) $_GET['pokemon'];
        $r = mysql_query("SELECT t.* FROM tags t, tags_images r WHERE r.tag_id =t.id AND r.image_id ='$image_id'");
        while($tag = mysql_fetch_assoc($r)) {
            echo $tag['name'] . '<br />';
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my current database structure is that I have places that consist of many tags.
I have a handler (c#/asp.net) that pulls images from a database. The current format
Current situation: I have a database with following structure: Product Category (contains column product_id)
As part of our current database work, we are looking at a dealing with
In our current database development evironment we have automated build procceses check all the
I just copied my current database to a new database to find out only
Does the MySQL command : FLUSH TABLES; flush every table in the current database,
Here is my current setup: Database Role - MyDbRole Schema - MySchema User -
i want to save current date+time into database and also want to retrieve it.
I want to display the current host and database names in a view. Where

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.