Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8700839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:15:40+00:00 2026-06-13T02:15:40+00:00

here we go: mysql> LOCK TABLES radcheck WRITE; Query OK, 0 rows affected (0.00

  • 0

here we go:

mysql> LOCK TABLES radcheck WRITE;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT * FROM radcheck WHERE id NOT IN (
    ->     SELECT id FROM (
    ->         SELECT id FROM radcheck  WHERE attribute = 'Password' GROUP BY UserName HAVING COUNT(*) > 1
    ->      ) AS c
    -> );
ERROR 1100 (HY000): Table 'radcheck' was not locked with LOCK TABLES

WTF?

EDIT

SET AUTOCOMMIT = 0
    -> ;
Query OK, 0 rows affected (0.00 sec)

mysql> LOCK TABLES radcheck WRITE;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT * FROM radcheck WHERE id NOT IN ( SELECT id FROM radcheck  WHERE attribute = 'Password' GROUP BY UserName HAVING COUNT(*) > 1 );
ERROR 1100 (HY000): Table 'radcheck' was not locked with LOCK TABLES



mysql> LOCK TABLES radcheck READ;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT * FROM radcheck WHERE id NOT IN ( SELECT id FROM radcheck  WHERE attribute = 'Password' GROUP BY UserName HAVING COUNT(*) > 1 );
ERROR 1100 (HY000): Table 'radcheck' was not locked with LOCK TABLES

pd: The query works fine if I not lock the table.
pd: This is only an examply ti simplify the question.. in real life is an DELETE…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:15:42+00:00Added an answer on June 13, 2026 at 2:15 am

    when you use lock tables, you need to lock all tables in your query.
    When you use a subquery it creates a table. and you are not locking it.
    because of that you are getting error.

    reference:
    http://dev.mysql.com/doc/refman/5.0/en/lock-tables.html

    give an alias to inner table

    tested sample:

    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)
    ) 
    

    And probably you need to this:

    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
     );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I lock mysql tables in php? I currently have this code: $db->query(LOCK
Here is my MySQL Query that im trying to execute. it keeps failing with
here is my mysql and php code layout: I have 3 tables tableA stores
I'm trying to get a std::string from my database using mysql connexion Here is
Here are my tables in mysql: ----------------1------------------------- +---------------------------+----------+ | email | attempts | +---------------------------+----------+
Here is my SQL 'SELECT u.`id`, u.`email`, u.`password`, u.`first_name`, u.`last_name`, u.`role_id`, MAX( ul.`datetime` )
This question here: MySQL: INSERT IGNORE or ON DUPLICATE KEY UPDATE with checking multiple
I've look all over the web and in the questions asked here about MySQL
a bit of a PHP / MySQL newbie here... I've been building a PHP-based
The in-house developed software where I work connects directly to a mysql server here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.