I am new to Grails criteria builder, can someone please explain what does the following mean?
def c = Account.createCriteria()
def results = c {
like("holderFirstName", "Fred%")
and {
between("balance", 500, 1000)
eq("branch", "London")
}
maxResults(10)
order("holderLastName", "desc")
}
Does it mean
Select * from account where‘)
holderFirstName like 'fred%' and
(balance between 500 and 1000 **and**
branch='londonSelect * from account where‘)
holderFirstName like 'fred%' and
(balance between 500 and 1000 **or**
branch='london
If i want to use “or” and “and” together how do I do that?
Your example would execute as:
All top level conditions are implied to be AND’ed together. You could create the same Criteria as:
To get your second query use this Criteria:
Nest your
and/orclosures for more complex Criteria.