我试图仅将新的更新连接到列updates
并更新其余列中的值,但我遇到了一些我似乎无法锻炼的障碍。
我的SQL看起来像这样:
$query="Update tickets SET product='$product',
p='$p',
i='$i',
summary='$summary',
workaround='$workaround',
concat(updates,'$additional_update'),
status='$status',
raised_by='$raised_by',
updated_by_user='$updated_by' WHERE id='$id'";
updates
列就像一个评论列,其中新的更新将附加到现有文本中。
我在网络服务器上收到的错误:
Update tickets SET product='T-Box', p='00000817766', i='-', summary='Testing update field
\r\nAdding an update\r\ntesting if null works for update', workaround='n/a', concat(updates,' ','test2@18:53:17:second update/n'), status='Open', raised_by='No', updated_by_user='test2' WHERE id='223'
直接在MySQL中运行查询:
#1064 - 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 '(updates,'test2@18:53:17:second update/n'), status='Open', raised_by='No', updat' at line 1
非常感谢帮助!
答案 0 :(得分:2)
您需要指定要设置此语句concat(updates,'$additional_update')
的值的位置。
Update tickets
SET product = '$product',
p = '$p',
i = '$i',
summary = '$summary',
workaround = '$workaround',
updates = CONCAT(updates,'$additional_update'), // <== see this
status = '$status',
raised_by = '$raised_by',
updated_by_user = '$updated_by'
WHERE id = '$id'
答案 1 :(得分:0)
试试这个:
$query="Update tickets SET product='$product',
p='$p',
i='$i',
summary='$summary',
workaround='$workaround',
updates=concat(updates,'$additional_update'),
status='$status',
raised_by='$raised_by',
updated_by_user='$updated_by' WHERE id='$id'";