gpt4 book ai didi

带有@符号的MySQL全文搜索产生错误 "syntax error, unexpected ' @', expecting $end"

转载 作者:IT老高 更新时间:2023-10-29 00:22:00 25 4
gpt4 key购买 nike

由于@(at 符号),以下查询会导致错误。删除后查询将正常工作。我尝试转义 @ 字符,但没有成功。

SELECT * FROM clients WHERE MATCH (form) AGAINST ('test@test.com' IN BOOLEAN MODE);

产生的错误是:

#1064 - syntax error, unexpected '@', expecting $end

请注意,我正在 phpMyAdmin SQL 控制台区域中测试这些查询,因此这不是我的其他编程的转义错误问题。

MySQL 服务器版本为 5.6.17。

有什么想法吗?谢谢。

最佳答案

这连接到 INNODB FULLTEXT 索引。

它是作为以下组合引入的:

  1. InnoDB full-text search does not support the use of multiple operators on a single search word

  2. @distanceThis operator works on InnoDB tables only. It tests whether two or more words all start within a specified distance from each other, measured in words.

http://dev.mysql.com/doc/refman/5.6/en/fulltext-boolean.html

# Running a test search for MATCH('+test{$ascii}test' IN BOOLEAN MODE) on all ASCII chars returns errors on:
40 (
41 )
64 @

MYSQL 似乎将这些符号视为分词符,我没有找到转义并将它们包含在实际查询中的方法,因此我的解决方案是拆分符号并将它们作为一个组包含,例如“test@bar” == (+test +bar)

# As a further test, running a search for MATCH('+{$ascii}' IN BOOLEAN MODE) returns errors for:
40 (
41 )
42 *
43 +
45 -
60 <
62 >
64 @
126 ~

这与 MYSQL 文档中预期的一样,是特殊的 BOOLEAN 修饰符

# As a testcase (Requires MYSQL 5.6+): 
CREATE TABLE `fulltext_innodb` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`text` text COLLATE utf8_unicode_ci,
PRIMARY KEY (`id`),
FULLTEXT KEY `text` (`text`)
) ENGINE=InnoDB
INSERT INTO `fulltext_innodb` (`id`, `text`) VALUES (1, 'test@bar');

SELECT * FROM `fulltext_innodb` WHERE MATCH (`text`) AGAINST( '+test@bar’ IN BOOLEAN MODE )

#1064 - syntax error, unexpected '@', expecting $end

关于带有@符号的MySQL全文搜索产生错误 "syntax error, unexpected ' @', expecting $end",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25088183/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com