mATOK Posted July 21, 2008 Share Posted July 21, 2008 Hi, I'm not sure how to explain what I want in my query but I will do my best I have a table that contains a key field, Ids, group ids and group names I have multiple rows for the same id. I want to find the IDs where data like below is present, i.e. more than 1 row contains a grouptypeid set to 1 and there is at minimum one row that contains a GroupTypeId set to 6 Key Field| ID |groupID |groupType | name 2312316 | 61232 | 2 | 1 | blahblah 2312317 | 61232 | 3 | 1 | lahblahb 2312318 | 61232 | 4 | 1 | ahblahbl 2312319 | 61232 | 6 | 6 | 123456 2312320 | 61232 | 7 | 6 | 234567 Quote Link to comment https://forums.phpfreaks.com/topic/115843-how-to/ Share on other sites More sharing options...
mATOK Posted July 21, 2008 Author Share Posted July 21, 2008 Something like this maybe SELECT * FROM Request_Group WHERE GroupTypeId='1' (And 1 appears on more than one row) AND WHERE GroupTypeId='6' ??? Quote Link to comment https://forums.phpfreaks.com/topic/115843-how-to/#findComment-595559 Share on other sites More sharing options...
mATOK Posted July 21, 2008 Author Share Posted July 21, 2008 select distinct requestid from request_group where grouptypeid = 6 and requestid in (select requestid from request_group where grouptypeid = 1 group by requestid, grouptypeid having count(*) > 1) Quote Link to comment https://forums.phpfreaks.com/topic/115843-how-to/#findComment-595726 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.