2019-02-25
閱讀量:
890
group_concat造成的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中多了一個(gè)逗號
group_concat執(zhí)行結(jié)構(gòu)有大小限制,會根據(jù)byte大小進(jìn)行截取







評論(0)


暫無數(shù)據(jù)
CDA考試動態(tài)
CDA報(bào)考指南
推薦帖子
0條評論
0條評論
0條評論
1條評論