首页 > 解决方案 > mysql将字符串转换为int不起作用(使用pdo)

问题描述

我想先将 memberID 从字符串转换为 int,然后在 mysql 中执行其他操作,但似乎只有 num 3 sql 工作,我该如何解决?否则,我有一个问题,为什么我通过 php int 类型输入 memberID 而 mysql 将其作为字符串插入?

select hasGivePoint from posts where postID=:postID and json_search(hasGivePoint,'one',(convert(:memberID ,signed))) is not null;


update
posts
set
$pointName=$pointName-1,hasGivePoint=JSON_REMOVE(hasGivePoint,replace(json_search(hasGivePoint,'one',
convert(:memberID ,signed)),'\"',''))
WHERE postID=:postID;
";


update posts set $pointName=$pointName+1,hasGivePoint=JSON_ARRAY_APPEND(hasGivePoint,'$',convert(:memberID ,signed)) where postID=:postID;

标签: mysql

解决方案


推荐阅读