0
我想使用CONCAT()將字符串附加到GROUP_CONCAT函數。 我試過如下:在GROUP_CONCAT()中附加<a href></a>()
$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
誰能請在解決這個幫助?
我逃脫了這樣的引號。但仍然得到相同的錯誤:( –
@Jen嘗試刪除這些引用太多並連接它(「。$ str1。」,bug_id,「。$ str2。」) – Fabio
GROUP_CONCAT CONCAT(「。$ str1。」,bug_id,「。$ str2。」)separator',') 嘗試過那樣,仍然是同樣的錯誤 –