The "Or" operator using SQL statement in Java

eforce

Registered User.
Local time
Yesterday, 19:58
Joined
Mar 25, 2002
Messages
44
Hello,

I'm working on a Java DB application and I'm having a problem with this SQL statement when using the "Or","|", or "||" operators.

Here is my code:

Data1.setRecordSource("SELECT * FROM tblUnit WHERE (MACOM) OR (DIVISION + MACOM) OR (CORPS + MACOM) OR (INSTALLATION) OR (BRIGADE + DIVISION) OR (BATTALION + BRIGADE) OR (BATTALION + CORPS) OR (BATTALION + DIVISION) OR (BRIGADE + MACOM) OR (USACHAPLAINCY) = '" +
frmUnit.Login.userName.getText() + "'");

It works perfectly with:

Data1.setRecordSource("SELECT * FROM tblUnit WHERE (BRIGADE + DIVISION) = '" + frmUnit.Login.userName.getText() + "'");



I've tried "OR" first ans so then I tried the "|" (or) in Java and "||" (logical or) in Java. I thought it was my concatenation but figured out that my concatenation was ok when I tried one combonation without the "OR" operator.


Please help!

Eforce
 
You need to specifically declare the condition at each or, so, (MACOM) = '" +
frmUnit.Login.userName.getText() + "'") OR (DIVISION + MACOM) = '" +
frmUnit.Login.userName.getText() + "'")

etc..

hth
 
Thanks Cross,

You helped me out alot. I finally got it to working.



Eforce.
 

Users who are viewing this thread

Back
Top Bottom