K
Kysely17mo ago
mike

How to write "SELECT 1 FROM tablename"

I want to create subquery for exists but don't know type select(1)...? should I use val or sql.lit or other way...? Thanks in advance https://kyse.link/?p=s&i=rF7gNapHXGQFdbmhVHJx
2 Replies
koskimas
koskimas17mo ago
You can use val or lit but you have to give the selection an alias even though it's usesless in this case. Otherwise kysely don't know what to add to the output type https://kyse.link/?p=s&i=9vWXxaSZTy5Qc6v8pSNU You get the same performance if you select a column like id though. select 1 is an optimization from the 80s before good query optimizers
mike
mikeOP17mo ago
fair enough. I've done it already with column name and it works as expected. thanks
Want results from more Discord servers?
Add your server