Hi Frank,

(almost) everything is possible but not always sensible.

First, an "OR" in a where clause is very rarely needed and should be avoided if 
possible. In your case e.g. it is much smarter to write:

  WHERE col1=val1 and col2 in (val2, val3)

In Empire-db you can write it like this:
  cmd.where(col1.is(val1).and((col2.in(new Object[] { val2, val3 })));

Or like this:
  cmd.where(col1.is(val1));
  cmd.where(col2.in(new Object[] { val2, val3 }));

I recommend the latter since it is much better understandable and you can 
easily enable or disable certain constraints.

But to answer your question for cases where it is not possible to avoid the 
"or":
The answer is that Empire-db sets parenthesis automatically depending on how 
you specify your constraints.

So if you want something like (col1=x and (col2=y or col3=z)) you'd write:
  cmd.where(col1.is(x));
  cmd.where(col2.is(y).or(col3.is(z));

Instead, if you want the condition to be ((col1=x and col2=y) or col3=z) you'd 
write:
  cmd.where(col1.is(x).and(col2.is(y)).or(col3.is(z));

In case of an "or" the parenthesis are automatically set from left to right.
Hope this has helped.

Regards
Rainer


Frank Lupo wrote:
> re: Query
> 
> I have a query:
> 
> ... WHERE col1=val1 and (col2=val2 or col2=val3)
> 
> In DBCommand is possible to specify the "(" ?
> 
> Thanks
> 
> 
>  --
>  Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP
> autenticato? GRATIS solo con Email.it http://www.email.it/f
> 
>  Sponsor:
>  Diventa uno dei magnifici 8! Entra a fare parte della squadra Italiana di
> Poker Sportivo con PokerClub
>  Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=8804&d=8-4

Reply via email to