by AlexErrant · 2y ago · 0 comments
WHERE
fa.rowid IN (SELECT rowid FROM address_fts WHERE address_fts MATCH 'google')
OR
ta.rowid IN (SELECT rowid FROM address_fts WHERE address_fts MATCH 'google')
Source https://sqlite.org/forum/forumpost?udc=1&name=1a2f2ffdd80cf7...I'm building a search feature for my app, that parses a user's search query (a la Github search) and returns relevant results. Generating the above workaround SQL on the fly is just... ulgh.
WITH matches(id) AS (
SELECT rowid FROM address_fts WHERE address_fts MATCH 'google'
)
...
WHERE
fa.rowid IN matches
OR
ta.rowid IN matches
You can also have more complex queries, such as if you want to match multiple domains (MATCH 'google OR gmail').It makes it slightly easier to generate queries since you only have to generate the CTE and then you can just use the CTE name everywhere else.