gpt4 book ai didi

php - 在 GROUP_CONCAT() 中附加

转载 作者:行者123 更新时间:2023-11-30 01:35:25 25 4
gpt4 key购买 nike

我想使用 CONCAT() 将字符串附加到 GROUP_CONCAT 函数。我尝试了以下方法:

$str1 = "<a href='show_bug.cgi?id ='>";
$str2 = "</a>";
$query = "select count(cbm.bug_id) as count,(select concat(round((count(cbm.bug_id)/(select count(*) from techzilla.category_bug_map cbm,techzilla.bugs b where b.assigned_to =$userId and cbm.bug_id=b.bug_id) * 100 ),2),'%')) as Percentage ,GROUP_CONCAT(CONCAT('$str1', bug_id,'$str2') separator ',') as BugIds from techzilla.bugs b left join techzilla.category_bug_map cbm on cbm.bug_id = b.bug_id where b.assigned_to = $userId and b.creation_ts >= '$fromDate 00:00:00' and b.creation_ts <= '$toDate 00:00:00' and cbm.os IN ('$opess')";

但是当我打印查询时,出现以下错误:

select count(cbm.bug_id) as count,(select concat(round((count(cbm.bug_id)/(select count(*) from techzilla.category_bug_map cbm,techzilla.bugs b where b.assigned_to =1078 and cbm.bug_id=b.bug_id) * 100 ),2),'%')) as Percentage ,GROUP_CONCAT(CONCAT('', bug_id,'') separator ',') as BugIds from techzilla.bugs b left join techzilla.category_bug_map cbm on cbm.bug_id = b.bug_id where b.assigned_to = 1078 and b.creation_ts >= '2013-05-01 00:00:00' and b.creation_ts <= '2013-06-06 00:00:00' and cbm.os IN ('Windows')
Bad query: 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 'show_bug.cgi?id ='>', bug_id,'') separator ',') as BugIds from techzilla.bug' at line 1

谁能帮忙解决这个问题吗?

最佳答案

由于 $str1 中的引用,您收到错误,我建议转义它们

$str1 = "<a href=\'show_bug.cgi?id =\'>";

这应该可以防止查询拆分字符串和 > 因为您的错误指向

关于php - 在 GROUP_CONCAT() 中附加 <a href></a>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16958567/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com