const mysql_mysql – 为什么我在解释查询中读取const表后会注意到“不可能”?
我在表中有一個像fr(fromid,toid)這樣的唯一復合鍵,當我使用explain運行查詢時,我得到以下結果:
Impossible WHERE noticed after reading const tables`
我跑的查詢:
explain SELECT rid FROM relationship WHERE fromid=78 AND toid=60
有幫助嗎?
EDIT1:
當我使用以下查詢時:
explain SELECT rid FROM relationship WHERE fromid=60 and toid=78 AND is_approved='s' OR is_approved='f' OR is_approved='t'
我看到USING WHERE而不是上一條消息,但是當我使用下面的查詢時:
explain SELECT rid FROM relationship WHERE fromid=60 and toid=78 AND (is_approved='s' OR is_approved='f' OR is_approved='t')
我再次得到第一個不可能的消息!這些括號在這里做什么?
EDIT2:
CREATE TABLE `relationship` (
`rid` int(10) unsigned NOT NULL AUTO_INCREMENT,
`fromid` mediumint(8) unsigned NOT NULL,
`toid` mediumint(8) unsigned NOT NULL,
`type` tinyint(3) unsigned NOT NULL,
`is_approved` char(1) NOT NULL,
PRIMARY KEY (`rid`),
UNIQUE KEY `fromid` (`fromid`,`toid`),
KEY `toid` (`toid`),
CONSTRAINT `relationship_ibfk_1` FOREIGN KEY (`fromid`) REFERENCES `user` (`uid`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `relationship_ibfk_2` FOREIGN KEY (`toid`) REFERENCES `user` (`uid`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB
Impossible WHERE noticed after reading const tables
MySQL has read all const (and system) tables and notice that the WHERE
clause is always false.
但是在查詢中我得到了我想要的結果,WHERE部分不是假的.是否有人可以解釋這一點,并闡明這個問題?
總結
以上是生活随笔為你收集整理的const mysql_mysql – 为什么我在解释查询中读取const表后会注意到“不可能”?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql的hash分区_MySQL中的
- 下一篇: mysql 配置分区_Mysql的分区配