-->
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: problem with syntax - join on the same table
PostPosted: Fri Jun 23, 2006 8:55 pm 
Newbie

Joined: Tue Jun 20, 2006 10:30 pm
Posts: 6
Hibernate 3.0.5

I am sorry that i totally messed up the description of the problem.

Here is the problem :

The table has 2 columns X1 and X2
Here is samle data for the example:

X1 X2
1 a
1 b
1 c
2 a
2 b
2 c
7 d
8 e


Here is what i tried :
Select count(*) from X xa left join X xb where xa.X2 = xb.X2 and
xa.X1 = '1' or xb.X1 = '2'
I expect an answer of 3.

This query fails with an parse exception. The error message is not helpful.

regards
-Sarab


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 24, 2006 12:22 pm 
Regular
Regular

Joined: Wed Jan 11, 2006 12:49 pm
Posts: 64
Location: Campinas, Brazil
You have to choose between a cross-product and a join. There seems to be no FK column in your table, so you cannot use a join. I do not use cross-products in HQL, but I suppose it would be something like this:
Code:
select count(*) from X xa, X xb where xa.X2 = xb.X2 and xa.X1 = '1' or xb.X1 = '2'

Not sure about the "count(*) though.

_________________
Henrique Sousa
Don't forget to rate useful responses


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.