Author Topic: Query help needed desperately  (Read 348 times)

0 Members and 1 Guest are viewing this topic.

Offline MaraclesTopic starter

  • Enthusiast
  • Posts: 87
    • View Profile
Query help needed desperately
« on: March 05, 2010, 07:13:27 PM »
I have 2 tables:

1 - title (the columns are: titleID, title)
2 - talent (the columns are: talentID, first_name, last_name)


Titles in the first table are film titles, and entries in the second tables are actors. There can therefore be multiple actors in one film. How do I show this?

I know I need a link table or some sort  so that if for example;

Indiana Jones = titleID of '1'
Harrison Ford = talentID of '1'
Steven Spielberg = talendID of '2'


The link table would show two columns:

col1 - titleID
col2 - talentID


The link table would then be:

titleID    talentID

1                 1
1                 2


I cannot figure out even after hours of trying how to select all talentID in the link table that have a titleID of 1. please help!


Offline fenway

  • MySQL Si-Fu / PHP Resident Alien
  • Global Moderator
  • 'Mind Boggling!'
  • *
  • Posts: 15,444
  • Gender: Male
    • View Profile
Re: Query help needed desperately
« Reply #1 on: March 13, 2010, 03:55:12 PM »
Why won't a simple join work?
:anim_rules: Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

Offline DaiLaughing

  • Enthusiast
  • Posts: 111
    • View Profile
    • Learn HTML, XHTML, CSS, Javascript, PHP and MySQL - Your Web Skills
Re: Query help needed desperately
« Reply #2 on: March 14, 2010, 03:29:37 AM »
A simple join would end up with a many-to-many relationship.  Each actor will be in many films but each film will have many actors.

You need an intervening table to record who was in what.  Film -> actedIn <- talent.

Can't think of a good name for the new table for some reason!

Offline fenway

  • MySQL Si-Fu / PHP Resident Alien
  • Global Moderator
  • 'Mind Boggling!'
  • *
  • Posts: 15,444
  • Gender: Male
    • View Profile
Re: Query help needed desperately
« Reply #3 on: March 19, 2010, 08:40:38 AM »
The OP wanted to query the table, not design it.
:anim_rules: Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.