ACC: Query with Subquery Returns Incorrect Result (171948)
The information in this article applies to:
- Microsoft Access 2.0
- Microsoft Access for Windows 95 7.0
- Microsoft Access 97
This article was previously published under Q171948 Moderate: Requires basic macro, coding, and interoperability skills.
SYMPTOMS
A query that contains a subquery that acts as criteria returns incorrect
results.
CAUSE
The query is based on an ODBC data source, and the ODBC driver incorrectly
interprets the data type of the subquery result as text.
WORKAROUND
There are two workarounds for this behavior:
- Use a SQL pass-through query.
- Try using a different SQL statement that would return the same
result. For example, change the SQL statement
SELECT DISTINCT a1.au_id FROM dbo_authors AS a1
WHERE 1 < (SELECT COUNT(*) FROM dbo_authors AS a2
WHERE a2.city = a1.city);
to the following:
SELECT DISTINCT a1.au_id FROM dbo_authors AS a1
WHERE a1.city In (SELECT a2.city FROM dbo_authors AS a2
GROUP BY a2.city HAVING (Count(a2.au_id)>1));
STATUS
Microsoft has confirmed this to be a problem in Microsoft Access versions
2.0, 7.0 and 97.
REFERENCES
For more information about subqueries, search the Help Index for
"subqueries" and display the topic "Use a subquery to define a field or
define criteria for a field."
For additional information, please see the following article in the
Microsoft Knowledge Base:
114678 How to Create and Use Subqueries
Modification Type: | Major | Last Reviewed: | 5/9/2003 |
---|
Keywords: | kbbug kbinterop KB171948 |
---|
|