mgutz / dat

Go Postgres Data Access Toolkit
Other
612 stars 62 forks source link

select exists #31

Closed nickmarx12345678 closed 8 years ago

nickmarx12345678 commented 8 years ago

Would nice to be able to do a SELECT EXISTS query without using string formatting

var trueFalse bool
sql := fmt.Sprintf("SELECT EXISTS(SELECT 1 FROM orders WHERE user_id = %v)", userId)
err := db.SQL(sql).
QueryScalar(&trueFalse)
mgutz commented 8 years ago

This is supported

err := db.SQL("SELECT EXISTS(SELECT 1 FROM orders where user_id = $1", userId).QueryScalar(&trueFalse)

Or are you requesting an Exists method?