How to query an external content FTS4 table but return additional columns from the original content table

前端 未结 1 780
孤街浪徒
孤街浪徒 2021-01-14 00:43

I am creating an FTS4 external content table in SQLite like this:

CREATE TABLE t2(id INTEGER PRIMARY KEY, col_a, col_b, col_text);
CREATE VIRTUAL TABLE fts_t         


        
相关标签:
1条回答
  • 2021-01-14 01:36

    FTS tables have an internal INTEGER PRIMARY KEY column called docid or rowid. When inserting a row in the FTS table, set that column to the primary key of the row in the original table.

    Then you can easily look up the corresponding row, either with a separate query, or with a join like this:

    SELECT *
    FROM t2
    WHERE id IN (SELECT docid
                 FROM fts_table
                 WHERE col_text MATCH 'something')
    
    0 讨论(0)
提交回复
热议问题