2
首先,這裏的表:MariaDB的,PBXT和神祕的查詢結果
CREATE TABLE `outlet_tags` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`importer_id` int(11) NOT NULL,
`outlet_id` int(11) NOT NULL,
`code` varchar(20) NOT NULL,
`postcode` varchar(15) DEFAULT NULL,
`tag_set` varchar(45) DEFAULT NULL,
`tag_type` varchar(45) DEFAULT NULL,
`tag_details` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_report_outlet_tags_1` (`importer_id`),
KEY `fk_report_outlet_tags_2` (`outlet_id`),
KEY `outlet_tag_set` (`tag_set`),
KEY `outlet_tag_type` (`tag_type`),
KEY `outlet_tag_details` (`tag_details`),
CONSTRAINT `fk_report_outlet_tags_1` FOREIGN KEY (`importer_id`) REFERENCES `importers` (`id`),
CONSTRAINT `fk_report_outlet_tags_2` FOREIGN KEY (`outlet_id`) REFERENCES `outlets` (`id`)
) ENGINE=PBXT DEFAULT CHARSET=utf8;
任何人都能夠解釋爲什麼字段值取決於下面的查詢中使用條件改變任何光線?如果發動機是瑪麗亞,那不會發生。
select * from outlet_tags where code=1503 and outlet_id=407 limit 3;
+------+-------------+-----------+------+----------+---------+-----------------+----------------+
| id | importer_id | outlet_id | code | postcode | tag_set | tag_type | tag_details |
+------+-------------+-----------+------+----------+---------+-----------------+----------------+
| 222 | 1 | 407 | 1503 | XXX XXX | outlet | Make up | Make up |
| 675 | 1 | 407 | 1503 | XXX XXX | outlet | Approved Status | Approved |
| 1619 | 1 | 407 | 1503 | XXX XXX | outlet | Retail Area | No Retail Area |
+------+-------------+-----------+------+----------+---------+-----------------+----------------+
3 rows in set (0.00 sec)
select * from outlet_tags where code=1503 and importer_id=1 limit 3;
+------+-------------+-----------+------+----------+---------+-----------------+----------------+
| id | importer_id | outlet_id | code | postcode | tag_set | tag_type | tag_details |
+------+-------------+-----------+------+----------+---------+-----------------+----------------+
| 222 | 1 | 407 | 1503 | XXX XXX | outlet | Make up | Make up |
| 675 | 1 | 407 | 1503 | XXX XXX | outlet | Approved Status | Approved |
| 1619 | 1 | 407 | 1503 | XXX XXX | outlet | Retail Area | No Retail Area |
+------+-------------+-----------+------+----------+---------+-----------------+----------------+
3 rows in set (0.00 sec)
select * from outlet_tags where importer_id=1 and outlet_id=407 limit 3;
+------+-------------+-----------+------+----------+---------+----------+-------------+
| id | importer_id | outlet_id | code | postcode | tag_set | tag_type | tag_details |
+------+-------------+-----------+------+----------+---------+----------+-------------+
| 222 | 1 | 407 | 1503 | NULL | NULL | NULL | NULL |
| 675 | 1 | 407 | 1503 | NULL | NULL | NULL | NULL |
| 1619 | 1 | 407 | 1503 | NULL | NULL | NULL | NULL |
+------+-------------+-----------+------+----------+---------+----------+-------------+
3 rows in set (0.00 sec)
更新:如MariaDB的5.5 PBXT was dropped as a storage engine
有誰認爲它可能是不正確的索引數據導致NULL值?第三個查詢是唯一在WHERE條件中僅使用索引字段的人 – Cez 2011-10-09 21:07:49