2017-08-30 123 views
0

我在MariaDB中发现了一些内容,我不知道如何调查或修复。它只发生在Windows上。 Linux上的MariaDB和Windows上的MySQL都运行良好。可能/可能我正在做一些明显错误的事情,但我很感兴趣。子查询在Windows中不工作,但在Linux上工作

我试图重现在一个简单的表中提供更多的信息,但它实际上工作,所以我不能再现。当然别的东西正在影响这种行为,但我不知道是什么。

问题:使用IN的子查询不起作用。这里是整个查询:

Select table1.entityKey 
from table1 
where table1.Deleted = 0 
and table1.MasterKey is null 
and table1.entityTypeKey = 8 
and table1.entityKey in 
    (select table2.entityKey 
    from table2 
    where table2.Flag <> 2 
    and (table2.IndexKey = 4 and MATCH (table2.xhtmltext) AGAINST ('gold'))) 
order by table1.entityKey DESC 

对于我的数据集,这应该返回值2和3,但给出了一个空集。

所以我分裂的疑问,我觉得这一点: 子查询正确返回2,3和4,

select table2.entityKey 
    from table2 
    where table2.Flag <> 2 
    and (table2.IndexKey = 4 and MATCH (table2.xhtmltext) AGAINST ('gold')) 

如果我这些值传递给外部查询,它正确地筛选出4,和给我正确的结果(2,3):

Select table1.entityKey 
from table1 
where table1.Deleted = 0 
and table1.MasterKey is null 
and table1.entityTypeKey = 8 
and table1.entityKey in 
    (2,3,4) 
order by table1.entityKey DESC 

这里有什么可能是错误的?

感谢

+0

如果一个子查询和外部查询返回单独正确的结果,但他们的组合不,这是一个错误的指示。请通过https://jira.mariadb.org报告。对于Windows/Linux的差异,很可能你在Linux和Windows上有不同的MariaDB版本,其中一个有一个错误,而另一个没有。比较每个服务器上的SELECT @@ version'的输出。另一个可能的原因是服务器设置不同,并且配置之一再次显示错误。如果版本相同,则比较“SHOW VARIABLES”的输出(忽略路径等)。 – elenst

+0

MyISAM? InnoDB的?两个系统都一样吗? –

+0

这似乎确实是版本10.2及以上的错误。将做更多的测试并报告问题。 – costateixeira

回答

0

它通常是最好避免IN (SELECT ...)地方实际。你的情况是很容易转变:

Select table1.entityKey 
    from table1 
    JOIN table2 USING(entityKey) 
    where table1.Deleted = 0 
     and table1.MasterKey is null 
     and table1.entityTypeKey = 8 
     and table2.Flag <> 2 
     and table2.IndexKey = 4 
     and MATCH (table2.xhtmltext) AGAINST ('gold')) 
    order by table1.entityKey DESC 

如果还是不行,请从两台机器提供EXPLAIN SELECT ...。也SHOW CREATE TABLE

相关问题