-->
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.  [ 1 post ] 
Author Message
 Post subject: Query question about pulling out unique values
PostPosted: Mon Dec 11, 2006 4:32 pm 
Newbie

Joined: Sat Jun 17, 2006 3:10 pm
Posts: 7
Location: Canada
I hava a table with a column called description. An ajax drop down runs the query, allowing users autocompletion for descriptions they have previously entered.

The problem I'm having is eliminating duplicate descriptions from the query. For example, if I had 300 rows with the description "computer", I only want to display "computer" once.

I can think of some hacky ways like storing the resulting list as a hashset with the description set as the key to filter out duplicates, but I'd prefer to have some way for the database to do it since I'd like to limit the results.

Here is the sql query. It works as you'd expect I just don't know how to say, only return one row if descriptions are equal to each other.

HQL:
Code:
select commodity from UsShipment shipment left join shipment.commodities commodity where shipment.carrierVersion.carrier.id = :carrierId and lower( commodity.description ) like :description order by lower( commodity.description )


Result is of type List<Commodity>...

Thanks in advance for any help...


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

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.