I believe it is the same question as if asking what is the difference between WHERE and WHERE EXIST ?!
Asked
Active
Viewed 2,357 times
1 Answers
1
.where()
creates a WHERE
clause, as in:
select `id` from `users` where `first_name` = 'Test' and `last_name` = 'User'
This clause is used to begin the conditional portion of a query.
.whereExists()
creates a WHERE EXISTS
clause, as in:
select * from `users` where exists (select * from `accounts` where users.account_id = accounts.id)
This clause tests for existence of rows in the subquery. In some cases, it is faster than using a JOIN
, as it does not join the entire table to the higher-level table (in the FROM
clause). More information at this other SO post
(These example queries were taken from the knex website)
Disclosure: I work for EnterpriseDB (EDB)

richyen
- 8,114
- 4
- 13
- 28