How to select values from an specific list of items
Posted: Wed Feb 17, 2010 9:30 am
Hi all, I am having problems trying to come up with a query that does the following. Let me try to explain.
I have these tables:
SKILLS
id
name
category_id
CATEGORIES
id
name
SKILL_CONFIGURATION
skill_id
category_id
What I want to do is get from the skill configuration table ALL of the configurations IF AND ONLY IF all of the categories are being used. For example:
ASsuming the following information is stored in the tables:
SKILLS
1, skill1
2, skill2
3, skill3
4,skill4
CATEGORIES
1,cat1
2,cat2
3,cat3
Having this configuration:
SKILL_CONFIGURATION
1,1
1,2
1,3
I expect to get three results, that I can do with a SELECT * FROM skill_configurations WHERE category_id IN(1,2,3)
However, if I have the following:
SKILL_CONFIGURATION
1,1
1,2
2,1
2,2
2,3
I want to get three rows (Only for skill 2 which has the three categories used) how can I do it? I'm lost
Thanks a lot!
I have these tables:
SKILLS
id
name
category_id
CATEGORIES
id
name
SKILL_CONFIGURATION
skill_id
category_id
What I want to do is get from the skill configuration table ALL of the configurations IF AND ONLY IF all of the categories are being used. For example:
ASsuming the following information is stored in the tables:
SKILLS
1, skill1
2, skill2
3, skill3
4,skill4
CATEGORIES
1,cat1
2,cat2
3,cat3
Having this configuration:
SKILL_CONFIGURATION
1,1
1,2
1,3
I expect to get three results, that I can do with a SELECT * FROM skill_configurations WHERE category_id IN(1,2,3)
However, if I have the following:
SKILL_CONFIGURATION
1,1
1,2
2,1
2,2
2,3
I want to get three rows (Only for skill 2 which has the three categories used) how can I do it? I'm lost
Thanks a lot!