Question on MySQL SELECT

This is a discussion on Question on MySQL SELECT within the PHP General forums, part of the PHP Programming Forums category; Hi everyone, I have created a table with the following 3 columns ID UserID SkillID 1 2 1 1 2 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-18-2005
Maziar Aflatoun
 
Posts: n/a
Default Question on MySQL SELECT

Hi everyone,

I have created a table with the following 3 columns

ID UserID SkillID
1 2 1
1 2 3
1 2 2
1 3 2

Is there a way to return all UserIDs that match SkillID=1 and SkillID=2 and
SkillID=3? (not OR)

Thank you
Maziar A.


Reply With Quote
  #2 (permalink)  
Old 05-21-2005
paulroskilly@hotmail.com
 
Posts: n/a
Default Re: Question on MySQL SELECT

Hi,

SELECT UserID, count(*) FROM t WHERE UserID >= 1 AND UserID <=3 GROUP
BY UserID HAVING count(*) = 3

This will return all user IDs that have 3 records of user ids between 1
and 3. The only reason is wouldn't work is if there were repeated rows
with the same userid and skillid.

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:57 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0