Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Sqlite reverse glob: The glob string is stored in the table and the constant string is in the query

Suppose I have this table:

name|match
a   |*
b   |?
c   |THIS
d   |THAT

Given a value via a replaceable parameter (?), I would like to select the rows where that value is matched by the glob pattern in match.

Examples:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

  1. Given ? == THIS expect the query to return rows a and c.
  2. Given ? == SELF expect the query to return row a.
  3. Given ? == A expect the query to return rows a, and b.

This does not work:

SELECT name from table WHERE match GLOB ?

My feeling is the way to achieve the desired behaviour is query without GLOB and then manually perform the glob in the code calling the query.

>Solution :

You have the operands backwards.

SELECT `name` FROM `table` WHERE ? GLOB `match`
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading