I am currently trying to issue an update to specific rows of a mysql query. Although some of the rows are not updating correctly. I am assuming this is because the query that I am trying to update is being derived from a bunch of join.
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'
Now….that query works fine in regards to returning the data I want. When I try to update the data this query returns with this statement:
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'
It says it has worked, but does not update the smownerid or the status of the ticket aside from assigning the values as null. Help is much appreciated.
The
ANDhere:should be a comma:
See the UPDATE syntax in the MySQL manual.