programing

하위 쿼리는 Windows에서 작동하지 않지만 Linux에서는 작동합니다.

codeshow 2023. 9. 19. 21:32
반응형

하위 쿼리는 Windows에서 작동하지 않지만 Linux에서는 작동합니다.

MariaDB에서 무언가를 찾고 있는데 어떻게 조사하거나 수정해야 할지 모르겠습니다.Windows(윈도우)에서만 발생합니다.리눅스의 MariaDB와 윈도우의 MySQL 모두 잘 작동합니다.아마도 제가 분명히 잘못하고 있는 것 같지만 호기심이 듭니다.

더 많은 정보를 제공하기 위해 간단한 표로 재현을 시도했지만 실제로는 재현할 수 없습니다.확실히 다른 무언가가 행동에 영향을 미치고 있지만 무엇인지 모르겠습니다.

문제: 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

뭐가 잘못됐나요?

감사해요.

보통 피하는 것이 최선입니다.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.

이것을 접한 사람들에게 이것은 정말 버그입니다: https://jira.mariadb.org/browse/MDEV-13704

언급URL : https://stackoverflow.com/questions/45964454/subqueries-do-not-work-in-windows-but-works-on-linux

반응형