一个奇怪的查询结果

今天发现一个奇怪的案例,Mysql版本是5.6.14-log.下面是具体重现该现象的脚本:(请无视里面的索引和数据数量,这里仅为了再现而精简了一些东西)
DROP
TABLE IF EXISTS `fdmt_is_merg_test`; CREATE TABLE `fdmt_is_merg_test` ( `ID` BIGINT(20) NOT NULL AUTO_INCREMENT, `TICKER_SYMBOL` VARCHAR(10) DEFAULT NULL, `END_DATE` DATE NOT NULL, PRIMARY KEY (`ID`), KEY `edate` (`END_DATE`,`TICKER_SYMBOL`), KEY `ix_ticker` (`TICKER_SYMBOL`) ) ENGINE=INNODB DEFAULT CHARSET=utf8; INSERT INTO `fdmt_is_merg_test`(`TICKER_SYMBOL`,`END_DATE`) VALUES ('000002','2006-03-30'),('000002','2006-03-31'); DROP TABLE IF EXISTS `md_security_test`; CREATE TABLE `md_security_test` ( `SECURITY_ID` BIGINT(20) NOT NULL , `TICKER_SYMBOL` VARCHAR(10) NOT NULL , `DYID` VARCHAR(50) DEFAULT NULL , PRIMARY KEY (`SECURITY_ID`), UNIQUE KEY `UK_DYID` (`DYID`) ) ENGINE=INNODB DEFAULT CHARSET=utf8; INSERT INTO `md_security_test`(`SECURITY_ID`,`TICKER_SYMBOL`,`DYID`) VALUES (0,'000002','000002.XSHE'); DROP VIEW IF EXISTS `vw_fdmt_is_test`; CREATE VIEW `vw_fdmt_is_test` AS SELECT `a`.`TICKER_SYMBOL` AS `TICKER_SYMBOL`,`b`.`DYID` AS `SECURITY_ID`,`a`.`END_DATE` AS `END_DATE` ,'1' AS `MERGED_FLAG`
,1 AS `MERGED_FLAG_int`
FROM (`fdmt_is_merg_test` `a` JOIN `md_security_test` `b` ON((`a`.`TICKER_SYMBOL` = `b`.`TICKER_SYMBOL`))); /*下面两个执行结果居然不一样*/ SELECT MERGED_FLAG FROM vw_fdmt_is_test;
SELECT MERGED_FLAG FROM vw_fdmt_is_test ORDER BY END_DATE DESC;
一个奇怪的查询结果_第1张图片
求各位Mysql大神指点为啥会这样...

 

你可能感兴趣的:(一个奇怪的查询结果)