I'm having trouble wrapping my head around how to do this...
So I've got three tables, directors, commercials, commercial_categories
Each commercial has a director_id and a commercial_category
How do I query all the directors with their commercial_categories, but only if commercials exist in that director's category? The original programmer of the site never created a table that links directors to commercial_category. Is there any way around this?
Complicated Join...
Moderator: General Moderators
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: Complicated Join...
This should not be a problem, it is common. Can you post your database schema so we can see exactly what you need.
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: Complicated Join...
You wont need a table that links directors with commercial categories - this link already exists by having directors related to a commercial, as commercials are then related with a cmmercial category.
One extremely good method for achieving your objective would be to use an INNER JOIN.
Take a look at this link for more info on joins http://www.w3schools.com/Sql/sql_join.asp
One extremely good method for achieving your objective would be to use an INNER JOIN.
Take a look at this link for more info on joins http://www.w3schools.com/Sql/sql_join.asp