I have a problem, where I can’t find help. When I delete the ORDER BY and LIMIT addtions, then this query works fine. But with them it causes an “Call to a member function execute() on a non-object”-Error. Using LEFT or INNER JOIN makes no difference.
$sql = "UPDATE tasks JOIN service
ON tasks_account_id = service_id
SET `tasks_status` = 'prog' ,
tasks_user = '".$user."'
WHERE `tasks_status` = 'free' AND `service_besetzt` = '0'
ORDER BY `tasks_client_date` ASC, `tasks_id` ASC
LIMIT ".$limit."";
$result = $db->prepare( $sql );
$result->execute();
Has someone an idea?
Thanks!
The issue is that you are using multiple-table UPDATE and ORDER BY and LIMIT clauses cannot be used with it; however they work nice with a single-table UPDATE. Please refer para 2 on http://dev.mysql.com/doc/refman/5.0/en/update.html.