Why cannot I query the data after a read lock is applied to the table?

Source: Internet
Author: User
Why cannot I query the data after a read lock is applied to the table?
mysql_query("LOCK TABLES tablename READ;");$result=mysql_query($sql, $conn);mysql_query("UNLOCK TABLES;");

After the first statement is commented out, the record can be queried normally, but once the first statement is used, nothing can be found.


Reply to discussion (solution)

You are not allowed to read it. how can you read it?

You are not allowed to read it. how can you read it?
However, I can write data after I add a write lock. Not only the current thread (maybe not the word) and other threads can read the read lock. Can anyone write the lock?

Please read the manual carefully before discussing it.

Please read the manual carefully before discussing it.
I cannot see the English section.

Is there a Chinese manual?

Is there a Chinese manual?
After you finish, I downloaded a Chinese file.
I didn't see anything about chinese. I saw the LOCK TABLES part. I tried that alias, but I still cannot.

Is there a Chinese manual?
I tried to read the lock on the MySQL command line interface. like the one on the Internet, it is the same as what I thought, but it won't work with PHP.

I found something wrong. My SELECT statement uses two tables, but I only lock one table. if only one table is locked, this thread or session can only read this table, and other tables will reject reading. In this way, the SELECT statement cannot find the result.
I was actually myself. I originally wrote a simple php program to test the error. this simple php program has been wrong. It may be the reason why the parameter is not changed after the copy and paste operation.
Wait for the post to sink and close the post. I hope others will not be so careless as I do.

Why can't I lock the table with this statement?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.