Page 1 of 1

hi, guys, help needed on generating such sql statement

PostPosted: Tue Oct 06, 2009 10:18 pm
by harrisonsu
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.

PostPosted: Wed Oct 07, 2009 5:49 am
by jigsaw
Hi harrisonsu.. You're at the wrong forum :)
You want this: http://www.subsonicproject.com/
but your are here: http://subsonic.sourceforge.net/

PostPosted: Wed Oct 07, 2009 8:42 am
by harrisonsu
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 .