db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Hepp <h...@evamann.de>
Subject is this really the way to combine several or´s ?
Date Wed, 22 Dec 2004 15:42:30 GMT
Hi List!

I tried several hours now, to get a simple or to work... I must say, that i 
really would appreciate a bit of documentation on that.

what i want now is this:
SELECT * FROM movii_user where (FIRST_NAME LIKE "%hello%" or LAST_NAME LIKE 
"%hello%" OR EMAIL LIKE "%hello%" or LOGIN_NAME="%hello%") AND IS_DELETED=0;

pretty simple. now, what i did is the following:

// just for demonstration i replaced a String by "hello"
userKeyWord = "%hello%";

Criteria crit = new Criteria();

Criteria.Criterion a1 = crit.getNewCriterion( MoviiUserPeer.LAST_NAME,
                             	(Object) (userKeyWord), Criteria.LIKE);

Criteria.Criterion a2 = crit.getNewCriterion(MoviiUserPeer.FIRST_NAME,
			 	(Object)userKeyWord, Criteria.LIKE);

Criteria.Criterion a3 = crit.getNewCriterion(MoviiUserPeer.LOGIN_NAME,
				(Object) userKeyWord, Criteria.LIKE);

Criteria.Criterion a4 = crit.getNewCriterion(MoviiUserPeer.EMAIL,
				(Object) userKeyWord,

Criteria.crit.add( a1.or( a2.or(a3.or(a4)) ));

is this really the right way, or am i completely wrong? It´s working though, but 
in my eyes pretty uncool;)

Would be cool, if someone could tell me, if this is realisable more easy...

Alex Hepp
büro für design & informatik evamann gbr

alex hepp, dipl. informatiker (fh) | alkuinstr. 24 | d-54290 trier
tel.: 0651 991 61 03  |  mobil: 0170 342 02 24
e-mail: hepp@evamann.de | www.evamann.de

View raw message