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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:13:18+00:00 2026-05-11T20:13:18+00:00

I asked a similar question yesterday which may have been poorly worded, either way

  • 0

I asked a similar question yesterday which may have been poorly worded, either way I didn’t understand and this is something I really need to crack 🙂 I’ve never done it before and would be very useful for so many of my projects.

This is for a directory website. I have three tables: entry, location, and entry-locations. entry contains information about a building such as name, address, image, etc. location is simply a list of possible locations each building could be. The location table is pretty much irrelevant for this example, it just contains information about the location which I could display on other areas of the site.

entry-locations is a table which links the entries to the locations. It only has two fields, entry-id and location… If you’re wondering why I need a seperate table for this is because the same building could have multiple locations (don’t ask).

Basically, what I need to do is display listings from each location it’s own page. For example, I need to list every building in France, so the query needs to go through the entry-locations table returning every record with the location ‘France’, then it needs to pull all the data from the entry table corresponding to the entry-id‘s returned.

I’m sure there is a way to do this with one query and would be extremely greatful if I could be shown how, I could replicate this in so many projects.

  • 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-11T20:13:18+00:00Added an answer on May 11, 2026 at 8:13 pm

    Imagine you have this data:

    Entry:

    |id|name|
    | 1|Foo |
    | 2|Bar |
    

    Entry-Location:

    |entry-id|location|
    |1       |France  |
    |2       |Greece  |
    |2       |France  |
    

    This is how I understand the tables from your description. A more common approach is to have

    Entry(id,name)
    Location(id,name)
    Entry_Location(entry_id, location_id)
    

    This is also the source of some of the confusions in the other posts, I think.

    Now, ask MySql to fetch data from both tables, where the id’s match up.

    SELECT entry.* 
    FROM `entry`, `entry-location` as el
    WHERE entry.id = el.`entry-id`
    AND el.location = 'France';
    

    MySql now treats your data like one table, looking like this:

    |entry.id|entry.name|el.location|
    |       1|       Foo|     France|
    |       1|       Foo|     Greece|
    |       2|       Bar|     France|
    

    And from that table it selects the entries where el.location = 'France', and returns the specified fields.

    This query fetches all the fields from the entry table that matches the requirements you set.
    First it makes MySql think of the two tables as one table, by SELECT-ing from both of them.

    Have a look at MySql’s SELECT reference.

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

Sidebar

Related Questions

I asked a question similar to this yesterday but have changed my code a
I asked a similar question like this yesterday but after waiting for ever I
I asked a similar question yesterday .. If I have for example 0-9999 ,
This one is similar to a question that I asked yesterday. However my concern
Morning, This is similar to a question i asked yesterday [question]: SQL query to
I have asked a similar question like this before but I am going to
I asked a similar question yesterday, but now I have a slight twist. Since
I asked a similar question yesterday, but have acquired a really odd problem since
This question is about a similar javascript scope problem that I asked yesterday .
This is similar to a question I asked yesterday but more specific to the

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.