når du bruger låsetabeller, skal du låse alle tabeller i din forespørgsel. Når du bruger en underforespørgsel, opretter den en tabel. og du låser den ikke. Derfor får du fejl.
reference:http://dev.mysql.com/doc /refman/5.0/da/lock-tables.html
give et alias til indre tabel
testet prøve:
lock tables products as p1 write, products as p2 write ;
select product_id from products as p1
where product_id not in (
select product_id from products p2 where product_id in (1,2)
)
Og sandsynligvis har du brug for dette:
lock tables radcheck as r1 write, radcheck as r2 write ;
SELECT * FROM radcheck r1 WHERE id NOT IN (
SELECT id FROM (
SELECT id FROM radcheck r2 WHERE attribute = 'Password' GROUP BY UserName HAVING COUNT(*) > 1) AS c
);