Hacker News new | ask | show | jobs
by Hakkin 919 days ago
I encountered similar issues with FTS5, I found you can clean it up slightly with a CTE

  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.