Question

This query dies when I try to execute it in PHP code and in phpMyAdmin.

UPDATE Inventory 
INNER JOIN InventorySuppliers 
ON Inventory.LocalSKU = InventorySuppliers.LocalSKU 
SET Inventory.Integer2 = '1' 
WHERE InventorySuppliers.SupplierSKU = '2D4027A6'

The error is:

1205 - Lock wait timeout exceeded; try restarting transaction

How can I prevent the lock timeout and/or solve this problem?

I can run this query in Microsoft Access correctly, and phpMyAdmin db is a copy of that Access database. Increasing the execution time is not an option for me as that will take too long for one record update.

$data1 = array('Inventory.Integer2'=>$shipping);

$this->db->where('InventorySuppliers.SupplierSKU', $SupplierSKU);
$this->db->update('Inventory inner join InventorySuppliers  on Inventory.LocalSKU = InventorySuppliers.LocalSKU', $data1);
$this->db->close();
return ($this->db->affected_rows() > 0);
Was it helpful?

Solution 2

Okay...Interesting for me... As I told you, My SQL db was a copy from ms access db...Dont know what happened, but mysql database tables dont have primay key or index although original db has have them...I tried asigning PK and indexes, but mysql returned me error, My final solution was

  • Delete thetable in mysql
  • Make sure PK is asigned in table structures ( In my cases, after importing from MS-Access, I have to do it again)
  • Check indexed feilds ( I have one feild indexed), and make sure index exists

and this did the trick for me, Now the same query is running okay...

thanks to all for the help...Hopes These two steps might help someone in future...

OTHER TIPS

Issue this command before running your UPDATE.

SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top