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.
id
(maybe the record whereb_id
is not null, ifid
is not unique).