hi, guys, help needed on generating such sql statement

Need help? Post your questions here.

Moderator: moderators

hi, guys, help needed on generating such sql statement

Postby harrisonsu » Tue Oct 06, 2009 10:18 pm

hi, guys.
I'm just stucked on generating such sql statement. any help would be appriciated.

select * from a where (a.id =1 or a.name='hello') and a.age=18

I use the following

SqlQuery query = new Select().From(a);
query.Or("id").IsEquals(1);
query.Or("name").IsEquals('hello');
query.And("age").IsEquals(18);

and it generates the following sql statement:

select * from a where a.id =1 or a.name='hello' and a.age=18

see? I need a "()" to include or statement otherwise it would means completely different from what I wanted.

so my question is how to add a "( )" to wrap "or" statement up.

Thanks.
harrisonsu
 
Posts: 2
Joined: Tue Oct 06, 2009 10:08 pm

Postby jigsaw » Wed Oct 07, 2009 5:49 am

Hi harrisonsu.. You're at the wrong forum :)
You want this: http://www.subsonicproject.com/
but your are here: http://subsonic.sourceforge.net/
Currently without Subsonic due to hardware failure :(
User avatar
jigsaw
 
Posts: 242
Joined: Sat Oct 13, 2007 12:01 pm
Location: Stavanger, Norway

Postby harrisonsu » Wed Oct 07, 2009 8:42 am

jigsaw wrote:Hi harrisonsu.. You're at the wrong forum :)
You want this: http://www.subsonicproject.com/
but your are here: http://subsonic.sourceforge.net/

whoops, silly me. thanks . ha ha ha .
harrisonsu
 
Posts: 2
Joined: Tue Oct 06, 2009 10:08 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 26 guests