mysql against,子查询(对AGAINST的错误参数)使用Mysql

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!

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值