Bool From JDBC

Is it possible to query a SQL database and, if the results have a column value matching a given string, return a boolean?

I am wanting to query a table whose results will return multiple rows. I want to check the column value for each returned row and, if any matches ex*, that is anything that starts with ex, return the value bool value of true. I don't need to know how many times it matches ex*, just whether or not it matches at least once.

Use a COUNT WHERE LIKE and then compare the resulting number with zero. Not sure if you can do the compare in the SQL statement.

1 Like

After some digging, I had success using the following query.

SELECT CAST(COUNT(1) AS BIT) FROM tablename WHERE user LIKE 'gates%' AND id = :id

This returns a 1 or 0 that logstash interprets as a bool.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.