I have the following query:
UPDATE pc
INNER JOIN cams
ON cams.cam_id = pc.camuid
SET
timestamp = NOW(),
uid = @out_param:=uid
WHERE zone = 1
AND (unable = '0' OR unable IS NULL)
AND (corrected_plate = '' OR corrected_plate IS NULL)
AND (timestamp IS NULL OR timestamp < (NOW() - INTERVAL @interval MINUTE))
LIMIT 1;
SELECT @out_param;
I am unable to run that query as I have a LIMIT
clause in a join query. I cannot figure out how to spread it out into a subquery while maintaining performance. I need this query to be as fast as possible, and the optimiser of MySQL has not provided much help so far.
This is the error obtained from MySQL, as the above is not allowed: Incorrect usage of UPDATE and LIMIT