-->
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: Left Fetch Join and Order By
PostPosted: Thu Mar 22, 2007 2:39 pm 
Newbie

Joined: Wed Dec 06, 2006 10:52 pm
Posts: 5
3.1.1
MySQL 5.0

Hi All,

I have a question on ordering while using left fetch join. I have two tables with a one-many relationship as follows :

table2.empId has a foreign key to table1.empId
table1.getEmpId() returns a collection of empId

table1
----------
empId
name
active

table2
----------
id
empId
showOrder
city

I do the following query

FROM Table1 AS tb1 LEFT JOIN FETCH tb1.empId WHERE tb1.active=1;

Now the question I have is - I need to order the elements (in ASC) returned by the previous query by table2.showOrder and table2.city. Can I accomplish this using LEFT JOIN FETCH or is there another easier way to do it ? Let me know



THanks
K


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 22, 2007 3:10 pm 
Newbie

Joined: Wed Dec 06, 2006 10:52 pm
Posts: 5
A small correction

table1.getTable2() returns a collection as opposed to table1.getEmpId()

Thanks
K


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.