K
Kysely•16mo ago
liteyear.

How can I write a count query?

Do I have to use raw SQL?
5 Replies
Igal (mobile)
Igal (mobile)•16mo ago
Hey 👋 use the ExpressionBuilder.
db.selectFrom('table')
.select((eb) => [
eb.fn.count('id').as('count_by_ref'),
eb.fn.countAll().as('count_with_nulls'),
])
.execute()
db.selectFrom('table')
.select((eb) => [
eb.fn.count('id').as('count_by_ref'),
eb.fn.countAll().as('count_with_nulls'),
])
.execute()
liteyear.
liteyear.OP•16mo ago
Thanks How can I count using innerjoins?
Igal (mobile)
Igal (mobile)•16mo ago
can you paste the SQL query you're trying to build
liteyear.
liteyear.OP•16mo ago
I think I figured it out! thanks @igalk
Unknown User
Unknown User•12mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server