简体   繁体   English

MYSQL - 语法错误,意外的“@”,期待 $end

[英]MYSQL - syntax error, unexpected '@', expecting $end

I'm trying to write a full-text search with the following SQL syntax:我正在尝试使用以下 SQL 语法编写全文搜索

SELECT   u.usuario AS `id`,
         Concat('(', u.usuario, ') ', u.nombre) AS `text`
FROM     usuarios AS u
WHERE    u.cuenta_id = 10
AND      MATCH (u.terminos) against ('jacuna@sgc.gov.co' IN boolean mode)
ORDER BY u.usuario ASC
LIMIT    50
  • u.usuario stores userID's string value u.usuario存储用户 ID 的字符串值
  • u.nombre stores user's full name u.nombre存储用户的全名
  • u.terminos stores some concatenated values to be used with AGAINST u.terminos存储一些与 AGAINST 一起使用的连接值

Example:例子:

if a user has the id '123456' and full name 'john doe' , the MySQL column 'terminos' will contain id + full name which means '123456 john doe'如果用户具有 id '123456'和全名'john doe' ,则 MySQL 列 'terminos' 将包含id + 全名,这意味着 '123456 john doe'

Note Sometimes user id can be an email, for that reason, it would have '@' character.注意有时用户 ID 可以是电子邮件,因此,它会有“@”字符。 When AGAINST value contains '@' I'm getting this error:AGAINST值包含 '@' 时,我收到此错误:

Syntax error, unexpected '@', expecting $end语法错误,意外的“@”,期待 $end

Thanks very much.非常感谢。

Put the phrase in double-quotes inside the single-quoted string.将短语放在单引号字符串内的双引号中。

I tested this on MySQL 5.6:我在 MySQL 5.6 上对此进行了测试:

mysql> SELECT u.usuario, terminos
  FROM usuarios AS u
  WHERE u.cuenta_id = 10 AND
       MATCH (u.terminos) AGAINST ('"jacuna@sgc.gov.co"' IN BOOLEAN MODE);
+---------+------------------------+
| usuario | terminos               |
+---------+------------------------+
|       1 | call jacuna@sgc.gov.co |
+---------+------------------------+

Read https://dev.mysql.com/doc/refman/8.0/en/fulltext-boolean.html :阅读https://dev.mysql.com/doc/refman/8.0/en/fulltext-boolean.html

A phrase that is enclosed within double quote (") characters matches only rows that contain the phrase literally, as it was typed. The full-text engine splits the phrase into words and performs a search in the FULLTEXT index for the words. Nonword characters need not be matched exactly: Phrase searching requires only that matches contain exactly the same words as the phrase and in the same order. For example, "test phrase" matches "test, phrase".包含在双引号 (") 字符中的短语仅匹配按字面意思键入的包含该短语的行。全文引擎将短语拆分为单词并在 FULLTEXT 索引中搜索单词。非单词字符不需要完全匹配:短语搜索只需要匹配包含与短语完全相同的单词并且顺序相同。例如,“测试短语”匹配“测试,短语”。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MySQL触发器“语法错误,意外的END,期待';'” - MySQL Trigger “syntax error, unexpected END, expecting ';'” MYSQL语法错误,意外IDENT_QUOTED,期待$ end - MYSQL syntax error, unexpected IDENT_QUOTED, expecting $end MySQL:语法错误,意外的'@',期望的':' - MySQL: Syntax error, unexpected '@', expecting ':' 使用@符号进行MySQL全文搜索会产生错误“语法错误,意外'@',期待$ end” - MySQL fulltext search with @ symbol produces error “syntax error, unexpected '@', expecting $end” Mysql2 :: Error sphinxql:语法错误,意外的',',期望$ end在',@@ SESSION.sql_auto_is_null = 0 - Mysql2::Error sphinxql: syntax error, unexpected ',', expecting $end near ', @@SESSION.sql_auto_is_null = 0 错误代码:1064 语法错误,意外的 $end,需要 FTS_TERM 或 FTS_NUMB 或 '*' MYSQL - Error Code: 1064 syntax error, unexpected $end, expecting FTS_TERM or FTS_NUMB or '*' MYSQL Tictactoe游戏期望IF MySQL的输入意外结束 - Tictactoe game Unexpected end of input expecting IF MySQL mysql意外END_OF_INPUT,期待IF - mysql unexpected END_OF_INPUT, expecting IF 意外的end_of_input输入,期望为';' MySQL的 - Unexpected end_of_input, expecting ';' mysql configuration.rb:14:in`instance_eval':(eval):16:语法错误,意外的输入结束,预期 - configuration.rb:14:in `instance_eval': (eval):16: syntax error, unexpected end-of-input, expecting
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM