Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用或锁定MySQL行_Mysql_Locking - Fatal编程技术网

使用或锁定MySQL行

使用或锁定MySQL行,mysql,locking,Mysql,Locking,我有以下疑问: SELECT * WHERE accountId = 1 AND (phone = "1234" OR fax = "5678") FOR UPDATE WHERE子句中的所有3列上都有键。accountId是索引,电话和传真与accountId组合以生成唯一索引: UNIQUE KEY `phone` (`phone`,`accountId`), UNIQUE KEY `phone` (`fax`,`accountId`), KEY `aid` (`aid`), 哪些钥匙将

我有以下疑问:

SELECT * WHERE accountId = 1 AND (phone = "1234" OR fax = "5678") FOR UPDATE
WHERE子句中的所有3列上都有键。accountId是索引,电话和传真与accountId组合以生成唯一索引:

UNIQUE KEY `phone` (`phone`,`accountId`),
UNIQUE KEY `phone` (`fax`,`accountId`),
KEY `aid` (`aid`),
哪些钥匙将被锁定?我需要的是使用phone=“1234”| fax=“5678”为accountId=1锁定行。已正确执行或优化,否则将锁定所有行

Mysql版本是5.0

试试

EXPLAIN SELECT * WHERE accountId = 1 AND (phone = "1234" OR fax = "5678") FOR UPDATE

以获取有关MySQL如何执行此语句的信息。

可能的密钥accountId,电话。使用的密钥是accountId。这是否意味着accountId=1的所有行都将被锁定,是否有办法解决此问题。也许把它分成两个查询?