If I remember correctly you can and two Criteria objects can't you? Sorry I don't have the source in front of me, it's on my laptop and it takes forever to boot up, but I think you might be able to accomplish this by creating two Criterias. The first will have just your COL_1='xxx' and the second will consist of COL_2='bla' || COL_3='blu' Then you should be able to AND those two Criteria objects together and get a result criteria from you can select on. I might just be dead wrong, but I suppose it's worth a shot. ;) Good luck.

-Brandon


----- Original Message ----- From: "Michael Schmitt" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Sunday, March 06, 2005 8:48 AM
Subject: Criteria: several columns OR-combined??



Hi,

I'm trying to create something like
SELECT * FROM table_a WHERE table_a.col_1='xxx' AND (table_a.col_2='bla' OR
table_a.col_3='blu')
with the Criteria class.


I tried something like this:

Criteria c = new Criteria();
c.add(TableAPeer.COL_1, 'xxx');
c.or(TableAPeer.COL_2, 'bla');
c.or(TableAPeer.COL_3, 'blu');
TableAPeer.doSelect(c);

but (of course) the Method or() relates the given criterion to an existing
criterion for the same column.
For example, something like
...
c.add(TableAPeer.COL_1, 'xxx');
c.or(TableAPeer.COL_1, 'yyy');
...
will probably (not tested) result in
... WHERE ... AND (table_a.col_1='xxx' OR table_a.col_1='yyy') ...


I thought that I could do something like
1. create a new criterion
2. pass the (table_a.col_2='bla' OR table_a.col_3='blu') to the criterion
3. add the criterion to the criteria
but as far as I understand, a criterion always relates to a single column.

any ideas?

greetings,
michael


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to