# How to lock these tables?

**URL:** <https://www.phphelp.com/t/how-to-lock-these-tables/9448>\
**Category:** MySQL database\
**Created:** [August 28, 2004, 12:48am UTC](https://www.phphelp.com/t/how-to-lock-these-tables/9448 "2004-08-28T00:48:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lcwsk](https://www.phphelp.com/letter_avatar_proxy/v4/letter/l/91b2a8/32.png) [@lcwsk](https://www.phphelp.com/u/lcwsk)\
**Post date:** [August 28, 2004, 12:48am UTC](https://www.phphelp.com/t/how-to-lock-these-tables/9448/1 "2004-08-28T00:48:34Z")

</div>

Information: MySQL version 4.0.20. The table S1 and follow\_up are MyISAM type.

* * *

mysql\> lock tables follow\_up write, S1 write;  
Query OK, 0 rows affected (0.00 sec)

## mysql\> INSERT follow\_up (reg\_no) SELECT S1.reg\_no FROM S1 LEFT JOIN follow\_up ON S1.reg\_no=follow\_up.reg\_no WHERE follow\_up.reg\_no IS NULL; ERROR 1100: Table ‘follow\_up’ was not locked with LOCK TABLES

If I use the following locking methods, they can not help yet.

1. lock tables follow\_up as S1 write;
2. lock tables S1 as follow\_up write;
3. lock tables follow\_up write;

How to lock these tables? Thanks!

---

<div class="post-metadata">

**Author:** ![lig](https://www.phphelp.com/letter_avatar_proxy/v4/letter/l/278dde/32.png) [@lig](https://www.phphelp.com/u/lig)\
**Post date:** [August 28, 2004, 5:08am UTC](https://www.phphelp.com/t/how-to-lock-these-tables/9448/2 "2004-08-28T05:08:10Z")

</div>

I think locking of tables can only be done using the InnDB table type.

---

<div class="post-metadata">

**Author:** ![lcwsk](https://www.phphelp.com/letter_avatar_proxy/v4/letter/l/91b2a8/32.png) [@lcwsk](https://www.phphelp.com/u/lcwsk)\
**Post date:** [August 28, 2004, 10:31am UTC](https://www.phphelp.com/t/how-to-lock-these-tables/9448/3 "2004-08-28T10:31:19Z")

</div>

I have tested that MyISAM tables can be locked.

---

<div class="post-metadata">

**Author:** ![lig](https://www.phphelp.com/letter_avatar_proxy/v4/letter/l/278dde/32.png) [@lig](https://www.phphelp.com/u/lig)\
**Post date:** [August 28, 2004, 8:56pm UTC](https://www.phphelp.com/t/how-to-lock-these-tables/9448/4 "2004-08-28T20:56:22Z")

</div>

In that case all I can give you is this

[http://dev.mysql.com/doc/mysql/en/LOCK\_TABLES.html](http://dev.mysql.com/doc/mysql/en/LOCK_TABLES.html)

Good luck ![:)]()

---

<div class="post-metadata">

**Author:** ![lcwsk](https://www.phphelp.com/letter_avatar_proxy/v4/letter/l/91b2a8/32.png) [@lcwsk](https://www.phphelp.com/u/lcwsk)\
**Post date:** [August 29, 2004, 4:37pm UTC](https://www.phphelp.com/t/how-to-lock-these-tables/9448/5 "2004-08-29T16:37:21Z")

</div>

I have found the useful information listed below. Thank you!

“Also, you cannot use a locked table multiple times in one query - use aliases for that. Note that in that case you must get a lock for each alias separately.”
