MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Anthony Mendoza Date:August 23 1999 7:47am
Subject:Help with query
View as plain text  
I'm hoping someone on this list can help me...

here's my table structure

tablename: userskills
columns: username,skillid,skillratingid

sample data

I need to write a query that will only return the usernames such that:
skillid = 1 AND skillratingid = 30
skillid = 2 AND skillratingid = 60

here is a query that returns the correct names, but is obviosly not the right query:

select username from userskills where 
(skillid = 1 and skillratingid = 30) or (skillid = 2 and skillratingid = 60)

This returns empty (obviously)...

select username from userskills where 
(skillid = 1 and skillratingid = 30) and (skillid = 2 and skillratingid = 60)

This needs to scale -> N skillid/skillratingid combinations.

If I need to create a cross-ref table and do join, I'm open to that.  This is a new
database and table structure so I have no problems re-arranging things.  I would, however,
like to avoid creating a new table if possible.  The basic info about the table is that it
stores the username of a person as well as the skills he has, with a rating.  I want to be
able to search the table for a specific set of skills/rating combos for a user that may
have 1 -> N combos being searched.  

Any help would be appreciated.  Please let me know if you need any other additional info.
Anthony Mendoza

Help with queryAnthony Mendoza23 Aug
  • Re: Help with queryChristian Mack8 Sep