I want to know that is there any way to lock MySQL tables without committing transaction implicitly. 

Suppose I have two tables (table\_1, table\_2) and I insert data in to these tables at the same time with transactions. And I need to lock 'table\_2' so that other users cannot write/modify 'table\_2' until the transaction is completed. My problem is When I lock table\_2 the transaction is committed implicitly. Yes I know it's explained in MySQL documentation

> 
> LOCK TABLES is not transaction-safe and implicitly commits any active
>  transaction before attempting to lock the tables
> 
> 
> 

I want to know that is there any other transaction safe method to do table locking.

Here is my C# code segment

```
MySQLTransaction trans = conn.BeginTransaction();
command.Transaction = trans;
command.CommandText = "INSERT INTO table_1 VALUES ('val1', 'val2')";
command.ExecuteNonQuery();

command.CommandText = "LOCK TABLES table_2 WRITE";
command.ExecuteNonQuery();

command.CommandText = "INSERT INTO table_2 VALUES ('val1', 'val2')";
command.ExecuteNonQuery();

command.CommandText = "RELEASE TABLES";
command.ExecuteNonQuery();

trans.Commit();

```

Any idea to lock and insert data to 'table\_2' without committing transaction?

Thanks in advance