Mysql查询在Mysql 5.6.10和5.6.46上未返回预期结果?
当我执行以下查询时:Mysql查询在Mysql 5.6.10和5.6.46上未返回预期结果?,mysql,database,Mysql,Database,当我执行以下查询时: SELECT node_field_data.title, node_field_data.type, node_field_data.status, node_field_data.nid, node_field_data.created AS node_field_data_created FROM node_field_data LEFT JOIN ( SELECT taxonomy_term_fi
SELECT
node_field_data.title,
node_field_data.type,
node_field_data.status,
node_field_data.nid,
node_field_data.created AS node_field_data_created
FROM
node_field_data
LEFT JOIN
(
SELECT
taxonomy_term_field_data.*,
taxonomy_index.nid
FROM
taxonomy_term_field_data
LEFT JOIN
taxonomy_index
ON taxonomy_index.tid = taxonomy_term_field_data.tid
WHERE
taxonomy_term_field_data.vid IN
(
'blog_post_tags'
)
)
taxonomy_term_field_data_node_field_data
ON node_field_data.nid = taxonomy_term_field_data_node_field_data.nid
WHERE
(
(taxonomy_term_field_data_node_field_data.name = 'lung cancer')
)
AND
(
(node_field_data.status = '1')
)
LIMIT 1;
我得到以下结果:
+------------------------------------------+-----------+--------+-------+-------------------------+
| title | type | status | nid | node_field_data_created |
+------------------------------------------+-----------+--------+-------+-------------------------+
| xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| blog_post | 1 | 14339 | 1332187581 |
+------------------------------------------+-----------+--------+-------+-------------------------+
然后我以以下方式添加where子句和(node\u field\u data.type IN('blog\u post')
SELECT
node_field_data.title,
node_field_data.type,
node_field_data.status,
node_field_data.nid,
node_field_data.created AS node_field_data_created
FROM
node_field_data
LEFT JOIN
(
SELECT
taxonomy_term_field_data.*,
taxonomy_index.nid
FROM
taxonomy_term_field_data
LEFT JOIN
taxonomy_index
ON taxonomy_index.tid = taxonomy_term_field_data.tid
WHERE
taxonomy_term_field_data.vid IN
(
'blog_post_tags'
)
)
taxonomy_term_field_data_node_field_data
ON node_field_data.nid = taxonomy_term_field_data_node_field_data.nid
WHERE
(
(taxonomy_term_field_data_node_field_data.name = 'lung cancer')
)
AND
(
(node_field_data.status = '1')
AND node_field_data.type = 'blog_post'
)
;
我没有得到任何结果(empty set(0.001秒)
在前面的查询中,类型blog\u post
存在
值得注意的是,在不同的mysql服务器版本
5.6.43
上使用相同的db数据是可行的。问题发生在mysql版本5.6.10
节点字段数据的数据类型是什么。type?如果是CHAR/VARCHAR?文本,则是开始查找非打印字符的时候了。添加LEN(节点\字段\数据类型)
对于您提出的第一个查询,如果不是9,那么可能就是问题所在。如果是enum…嗯,enum很奇怪。尽管MySQL版本有不同,但我认为这不是一个非打印字符问题,除非数据的记录/还原略有不同。谢谢,这是一个很好的猜测,但它是varchar(32)和返回的长度9可能会检查表中是否有错误?如果该字段已编制索引,且索引以某种方式过期或损坏,则可能会导致类似问题。