我在表中有一个像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部分不是假的.是否有人可以解释这一点,并阐明这个问题?