Jump to content

Recommended Posts

I have 3 tables for my website, Locations, Attractions and Location_Attractions (stores which attractions can be found at the different locations)

 

I am

Locations
id   name
1    Las Vegas

Attractions
id   name
1    Casino
2    Hotel

Location_Attractions
location_id    attraction_id
1                   1
1                   2

 

trying to get my head round how I perform a query to show which locations a certain attraction can be found at. For example on the Casino page I am going to list oll of the locations this can be found at.

 

So I know I need to query Location_Attractions to find all of the locations that have the correct attraction_id (eg 1 for Casino). I then need to link this to the Locations table to retrieve the details about the locations (such as name, address). Any idea how I would do this, would I use a JOIN?

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/242477-query-question/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.