Skip to main content
3 of 3
added 8 characters in body; edited title
Paul White
  • 90.3k
  • 30
  • 424
  • 663

Getting Database is locked error

I have a query in which I am updating a table and have used IN keyword in the query. The query is something like this:

UPDATE q 
SET b_id = 123     
WHERE id IN (SELECT id FROM q WHERE b_id IS NULL LIMIT 1)

There is another query in which I am inserting data in table. The query is:

INSERT INTO q (id, item) VALUES (@id, @item)

The queries are executing on different threads. While executing the second (INSERT) query I am getting database is locked error.

What is the reason?

id is not primary key.