子查询(对AGAINST的错误参数)使用Mysql [英] subquery (Incorrect arguments to AGAINST) using Mysql

查看:761
本文介绍了子查询(对AGAINST的错误参数)使用Mysql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我通过 MATCH AGAINST 使用MySql(查看第1个查询)执行此查询时, (参见错误),或者当我使用 = 执行相同的查询时,它们会正常执行(参见第二个查询) 。



我的问题是我在做什么反对声明错误?


Query 1st



  SELECT(SELECT COUNT(up.`user_id`)
FROM `users_post` up WHERE MATCH(up.`user_id`)AGAINST(uf.`user_id`))
AS user_count
FROM`users` uf




错误




 在此处输入代码错误代码:1210 
对AGAINST
(需要0 ms)的错误参数



更新


查询第二位

blockquote>

  SELECT 
(SELECT COUNT(up.`user_id`)
FROM`users_post` up WHERE up.`user_id` = uf.`user_id`)
AS user_count
FROM`users `uf


解决方案

问题在于 AGAINST 必须是一个文字字符串,例如'Fred'。不允许使用列名称,如 uf.user_id

  MATCH(up.`user_id`)AGAINST(uf.`user_id`)
- ^^^^^^^^^^^^不允许!

文档


搜索字符串必须是一个文字字符串,不是一个变量或一个列名。

您可能需要使用 LIKE 而不是 MATCH ,但你应该注意它会慢得多。


When I execute this query with MATCH AGAINST using MySql (see Query 1st) the issue in this query they has generated an error like this (see error) or when I execute the same query with = they executed normally(see Query 2nd).

My question is what am I doing wrong with against statement?

Query 1st

SELECT (SELECT COUNT(up.`user_id`) 
FROM `users_post` up WHERE MATCH (up.`user_id`) AGAINST (uf.`user_id`)) 
AS user_count 
FROM `users` uf

Error

enter code hereError Code : 1210
Incorrect arguments to AGAINST
(0 ms taken)

Update

Query 2nd

SELECT 
(SELECT COUNT(up.`user_id`) 
FROM `users_post` up WHERE up.`user_id` = uf.`user_id`) 
AS user_count 
FROM `users` uf

解决方案

The problem is that the argument for AGAINST must be a literal string, for example 'Fred'. It is not allowed to use a column name like uf.user_id.

MATCH (up.`user_id`) AGAINST (uf.`user_id`)
--                            ^^^^^^^^^^^^ not allowed!

From the documentation:

The search string must be a literal string, not a variable or a column name.

You probably need to use LIKE instead of MATCH, though you should note that it will be much slower.

这篇关于子查询(对AGAINST的错误参数)使用Mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆