我目前正在尝试对mysql查询的特定行发布更新。虽然有些行没有正确更新。我假设这是因为我试图更新的查询来自一堆连接。
SELECT
vtiger_users.user_name,
vtiger_troubletickets.*,
vtiger_crmentity.*
FROM
vtiger_troubletickets
LEFT JOIN(
vtiger_crmentity,
vtiger_users
)ON(
vtiger_crmentity.crmid = vtiger_troubletickets.ticketid AND
vtiger_crmentity.smownerid = vtiger_users.id
)WHERE
vtiger_troubletickets.status != "Closed"
UPDATE vtiger_troubletickets
LEFT JOIN(vtiger_crmentity, vtiger_users
)ON
(vtiger_crmentity.crmid = vtiger_troubletickets.ticketid AND vtiger_crmentity.smownerid = vtiger_users.id) SET smownerid = '6'
WHERE ticket_no='TT63'
现在....该查询在返回我想要的数据方面工作正常。当我尝试更新数据时,此查询将返回以下语句:
UPDATE vtiger_troubletickets t
LEFT JOIN (vtiger_crmentity, vtiger_users)
ON (vtiger_crmentity.crmid = t.ticketid
AND vtiger_crmentity.smownerid = vtiger_users.id)
SET smownerid='1' AND t.status='Abandon'
WHERE t.ticket_no='TT63'
它表示它已经有效,但除了将值指定为null之外,不会更新smownerid或票证的状态。非常感谢帮助。
答案 0 :(得分:2)
此处AND
:
SET smownerid='1' AND t.status='Abandon'
应该是逗号:
SET smownerid='1', t.status='Abandon'
请参阅MySQL手册中的UPDATE syntax。
UPDATE [LOW_PRIORITY] [IGNORE] table_references SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ... [WHERE where_condition] ^ ^ comma