Hi Folks,
I am trying to use OR condition in my Select statement; so ComboCondition is the right choice for that I think: http://openhms.sourceforge.net/sqlbuilder/apidocs/com/healthmarketscience/sqlbuilder/ComboCondition.html http://openhms.sourceforge.net/sqlbuilder/apidocs/com/healthmarketscience/sqlbuilder/ComboCondition.html#or%28%29
http://openhms.sourceforge.net/sqlbuilder/syntax_reference.html
But what I am not able to figure out the way to use ComboCondition with Selectquery.
What I tried, but not working:
selectQuery1.addCondition(ComboCondition.or(BinaryCondition.lessThan(_defTable1_col1, inputColumn.get(Constants.VALUE), false)));
Can someone please show me with example code?
Thank you in advance.
Your code is exactly right. Since your "or" condition only has one clause, you won't see an "OR" in your final output.
You can see a lot of example code here: http://openhms.sourceforge.net/sqlbuilder/xref-test/com/healthmarketscience/sqlbuilder/SqlBuilderTest.html
Thank you.
I have tried above url thatyou provided.
My issue is like:
selectQuery1.addCondition(ComboCondition.or(BinaryCondition.greaterThan(_defTable1_col1, inputColumn.get(Constants.VALUE), false)));
I am trying to combine these 2 queries using OR; these queries are coming from a for loop, with the increment of i;
Thanks again
Then you need to keep a handle to the ComboCondition that you created and continue to add the BinaryConditions to it:
ComboCondition orCond = ComboCondition.or(); selectQuery1.addCondition(orCond); for( ... ) { orCond.addCondition(BinaryCondition.lessThan(_defTable1_col1, inputColumn.get(Constants.VALUE), false))); }
A ComboCondition is a "container" which holds all of the conditions which will be combined by a given operator.
Log in to post a comment.
Hi Folks,
I am trying to use OR condition in my Select statement; so ComboCondition is the right choice for that I think:
http://openhms.sourceforge.net/sqlbuilder/apidocs/com/healthmarketscience/sqlbuilder/ComboCondition.html
http://openhms.sourceforge.net/sqlbuilder/apidocs/com/healthmarketscience/sqlbuilder/ComboCondition.html#or%28%29
http://openhms.sourceforge.net/sqlbuilder/syntax_reference.html
But what I am not able to figure out the way to use ComboCondition with Selectquery.
What I tried, but not working:
selectQuery1.addCondition(ComboCondition.or(BinaryCondition.lessThan(_defTable1_col1, inputColumn.get(Constants.VALUE), false)));
Can someone please show me with example code?
Thank you in advance.
Your code is exactly right. Since your "or" condition only has one clause, you won't see an "OR" in your final output.
You can see a lot of example code here: http://openhms.sourceforge.net/sqlbuilder/xref-test/com/healthmarketscience/sqlbuilder/SqlBuilderTest.html
Last edit: James Ahlborn 2014-12-13
Thank you.
I have tried above url thatyou provided.
My issue is like:
selectQuery1.addCondition(ComboCondition.or(BinaryCondition.lessThan(_defTable1_col1, inputColumn.get(Constants.VALUE), false)));
selectQuery1.addCondition(ComboCondition.or(BinaryCondition.greaterThan(_defTable1_col1, inputColumn.get(Constants.VALUE), false)));
I am trying to combine these 2 queries using OR; these queries are coming from a for loop, with the increment of i;
Thanks again
Then you need to keep a handle to the ComboCondition that you created and continue to add the BinaryConditions to it:
A ComboCondition is a "container" which holds all of the conditions which will be combined by a given operator.
Last edit: James Ahlborn 2014-12-15