SQLite3、匹配和或

发布于 2024-11-14 23:31:35 字数 432 浏览 2 评论 0原文

MATCHOR 组合是否有效?

例如,

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

不会生成任何命中,而

SELECT * FROM myTable WHERE name MATCH 'andrew';< /code> 和

SELECT * FROM myTable WHERE name MATCH 'bill';

确实给出了命中。

%%

编辑。带有 OR 错误代码的选择是 1,因此它的格式有些错误。第二个和第三个的结果是 0,所以它们没问题。我不确定出了什么问题。

Is it valid to combine MATCH with OR?

For example,

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

does not generate any hits, while both

SELECT * FROM myTable WHERE name MATCH 'andrew'; and

SELECT * FROM myTable WHERE name MATCH 'bill';

do give hits.

%%

Edit. The select with OR error code is 1, so it's malformed some how. The result on the second and third is 0 so they're fine. I'm not sure what's wrong.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

故事灯 2024-11-21 23:31:35

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

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

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

SELECT * FROM myTable WHERE name MATCH 'andrew OR bill'
烈酒灼喉 2024-11-21 23:31:35
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 不是 LIKE GLOB MATCH REGEXP

或者

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

<前><代码>- + ~ NOT

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

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 understands the following binary operators,
in order from highest to lowest precedence:

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

OR

Supported unary prefix operators are these:

-    +    ~    NOT

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文