2012-10-26 86 views
0

假設我有一個FTS [34]表data和一個常規表info,它們被info.ID = data.rowid綁定在一起。我有一個視圖master表示這個連接,我用它來查詢整體信息。 這裏是CREATE TABLE聲明:SQLite查看功能?

CREATE VIRTUAL TABLE data USING fts4(
    Name, 
    Keywords, 
    Aliases 
    Description); 

CREATE TABLE info (
    ID INTEGER PRIMARY KEY, 
    -- A bunch of other columns... 
    ); 

CREATE VIEW master AS SELECT 
    info.ID AS ID 
    data.Name AS Name, 
    data.Keywords AS Keywords, 
    data.Aliases AS Aliases, 
    data.Description AS Description, 
    -- A bunch of other columns... 
FROM info JOIN data ON info.ID = data.rowid; 

現在我想要做的就是創造另一種觀點認爲,由於對每列執行,而不是選擇從data表整個小區,選擇SQLite的snippet函數的結果在data表:

CREATE VIEW search AS SELECT 
    master.*, 
    snippet(data '<b>', '</b>', '...', 0) AS sn_Name, 
    snippet(data '<b>', '</b>', '...', 1) AS sn_Keywords, 
    snippet(data '<b>', '</b>', '...', 2) AS sn_Aliases, 
    snippet(data '<b>', '</b>', '...', 3) AS sn_Description 
FROM master JOIN data ON master.ID = data.rowid; 

然而,當我從內Python中執行該語句,我得到如下:

sqlite3.OperationalError: near "'<b>'": syntax error 

回答

1

缺少參數值data'<b>'之間的逗號。