subquery (Incorrect arguments to AGAINST) using Mysql

霸气de小男生 提交于 2019-12-04 03:35:08

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/10465758/subquery-incorrect-arguments-to-against-using-mysql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!