IT行业相对于一般传统行业,发展更新速度更快,一旦停止了学习,很快就会被行业所淘汰。所以我们需要踏踏实实的不断学习,精进自己的技术,尤其是初学者。今天golang学习网给大家整理了《【mysql】[error]group_concat造成的sql语法错误》,聊聊MySQL、PHP,我们一起来看看吧!
sql错误实例
$sql_id = "select group_concat(`table_a_id`) from `table_b`";
$id_str = $db->execute($sql_id);
$sql = "select * from `table_a` where `id` in ( {$id_str} ) and `is_effect` = 1`";
$res = $db->execute($sql);
/*
error:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right
syntax to use near ') and `is_effect` = 1'
*/
// 完整sql: select * from `table_a` where `id` in ( 1,2,3,4, ) and `is_effect` = 1`
错误原因
sql中多了一个逗号
group_concat 执行结构有大小限制,会根据byte大小进行截取

今天关于《【mysql】[error]group_concat造成的sql语法错误》的内容介绍就到此结束,如果有什么疑问或者建议,可以在golang学习网公众号下多多回复交流;文中若有不正之处,也希望回复留言以告知!
本文内容来源于互联网,如有侵权请联系删除。
