Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create Nested Or/And clauses? #43

Open
gitcloned opened this issue Aug 28, 2018 · 1 comment
Open

How to create Nested Or/And clauses? #43

gitcloned opened this issue Aug 28, 2018 · 1 comment

Comments

@gitcloned
Copy link

How to generate the query clause with nested and/or, example:

Select departmentName, departmentSales
From Department
Where
  EmployeeCount > 1000
  AND (  DepartmentRevenue > 100000 OR DepartmentCost > 10000 )
@kylefarris
Copy link
Owner

At the moment, you have to escape a manually-written where clause and tell the where method to not try and escape it for you by passing false to the third parameter. There's already an Issue in for the request to add this to the actual API (#29). To do it manually, you would do the following:

qb.select('departmentName', 'departmentSales')
    .where('EmployeeCount >', 1000)
    .where('`DepartmentRevenue` > 100000 OR `DepartmentCost` > 10000', null, false)
   .get('Department')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants