SQLite3,MATCH和OR

时间:2011-06-11 04:43:52

标签: sqlite match

MATCHOR结合使用是否有效?

例如,

SELECT * FROM myTable WHERE name MATCH 'andrew' OR name MATCH 'bill';

不会产生任何命中,而两者都

SELECT * FROM myTable WHERE name MATCH 'andrew';

SELECT * FROM myTable WHERE name MATCH 'bill';

确实给予点击。

%%

编辑。带有OR错误代码的选择是1,所以它有些不正确。第二个和第三个的结果是0所以它们很好。我不确定是什么问题。

2 个答案:

答案 0 :(得分:5)

http://www.sqlite.org/fts3.html#section_3

SELECT * FROM myTable WHERE name MATCH 'andrew OR bill'

答案 1 :(得分:0)

SELECT * FROM myTable WHERE name MATCH 'andrew OR bill'

SELECT * FROM myTable WHERE name MATCH ('andrew' OR 'bill')

c.execute("SELECT * FROM myTable WHERE name MATCH (? OR ?)", ('andrew', 'bill'))
#safe from SQL injection attacks by escaping the variables.
  

SQLite了解以下二元运算符,   从最高优先级到最低优先级:

||
*    /    %
+    -
<<   >>   &    |
<    <=   >    >=
=    ==   !=   <>   IS   IS NOT   IN   LIKE   GLOB   MATCH   REGEXP
AND

OR
     

支持的一元前缀运算符如下:

-    +    ~    NOT

https://www.sqlite.org/lang_expr.html