-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Help with query
PostPosted: Wed Nov 05, 2008 5:38 pm 
Newbie

Joined: Wed Nov 05, 2008 5:35 pm
Posts: 3
Hi all,
I need help with the following query....

Code:
-------------------------------------------------------------------------------
select distinct queue
from Queue queue
join queue.queueSongRequestLookups queueLookup
where queueLookup.songRequest.songRequestStatusType = ?
-----------------------------------------------------------------------------


Basically here we have 3 tables; Queue , songRequest, and queueSongRequestLookup. There is a many to many relationship between Queue and songRequest so queueSongRequestLookup is the lookup table.

Now what I want is only the Queues that have all songRequests with songRequestStatusType as 11.

The query above does get me the Queues that have songRequests with songRequestStatusType as 11 but it also returns Queues that have songRequestStatusType other than 11. Basically if there is even one songRequest with Status of 11 this query will return it. This is not what I need. I need all the songRequests in that Queue have status of 11, only then should it be returned.

Anyone have any suggestions?

Thanks in advance for any help.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 05, 2008 6:50 pm 
Newbie

Joined: Mon Apr 14, 2008 5:38 pm
Posts: 4
Maybe something like this:

Code:
select queue
from Queue queue
where not exists (from queueSongRequestLookups queueLookup
   where queueLookup.pk = queue.pk and queueLookup.songRequest.songRequestStatusType <> ?)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.