I’m trying to check if a specific ID exists in a table named “Products” in my sqlite database.
def existsCheck( db, id )
temp = db.execute( "select exists(
select 1
from Products
where promoID = ?
) ", [id] )
end
that’s my current code but that returns an array which means I have to deal with conversion before I can use it as a boolean. Any ideas how I can change it so that it returns an int with the value 1?
There is no need to use a subquery:
This returns a boolean result.