Skip to content

[BUG] Wrong results using a subquery in an IN clause #649

Description

@hiroyuki0415
SELECT e3.primaryid,
	e2.some_column
FROM entity3 AS e3
INNER JOIN entity2 AS e2 ON e3.entity2id = e2.primaryid
INNER JOIN entity1 AS e1 ON e2.entity1id = e1.primaryid
INNER JOIN entity0 AS e0 ON e1.entity0id = e0.primaryid
WHERE e2.primaryid IN (
		SELECT _e2.primaryid
		FROM entity2 AS _e2
		INNER JOIN entity1 AS _e1 ON _e2.entity1id = _e1.primaryid
		INNER JOIN entity0 AS _e0 ON _e1.entity0id = _e0.primaryid
		WHERE _e2.some_column = 948370000 --PicklistType
			AND (
				_e0.some_column = 0
				OR _e2.some_column IN ('xxx')
				)
		);

In the execution result of this SQL,

  • expected
    For all records[some_column] =948370000
    (In fact, if you run it in ADS, that's what happens.)
  • actual
    [some_column] !=948370000 records exist
    Image

Environment

  • SQL 4 CDS edition: XrmToolBox
  • Results of SELECT @@VERSION:
Microsoft Dataverse - 9.2.25023.180
   SQL 4 CDS - 9.6.0.0
   2 23 2025 06:26:13
   Copyright © 2020 - 2024 Mark Carrington

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions