英文:
Second Sub-SELECT statement not returning value with UNION
问题
为什么这个查询...
SELECT DISTINCT [COS_JobTitle] AS 'Name'
FROM (
SELECT [COS_BpsID] AS [COS_BpsID], [COS_JobTitle] AS [COS_JobTitle]
FROM [CacheOrganizationStructure]
WHERE [COS_AccountType] = 1
UNION
SELECT WFD_AttChoose3 AS WFD_AttChoose3, NULL
FROM WFElements
WHERE WFD_ID = 53584
) AS nnn
ORDER BY 'Name'
...没有返回第二个子查询语句的值?
SELECT WFD_AttChoose3 AS WFD_AttChoose3, NULL
FROM WFElements
WHERE WFD_ID = 53584
一旦我修改整个查询,省略每个子查询语句的第二列,它就能如预期般工作,即, [COS_JobTitle] AS [COS_JobTitle]
和 ,NULL
。
英文:
Why does this query...
SELECT DISTINCT [COS_JobTitle] AS 'Name'
FROM (
SELECT [COS_BpsID] AS [COS_BpsID], [COS_JobTitle] AS [COS_JobTitle]
FROM [CacheOrganizationStructure]
WHERE [COS_AccountType] = 1
UNION
SELECT WFD_AttChoose3 AS WFD_AttChoose3, NULL
FROM WFElements
WHERE WFD_ID = 53584
) AS nnn
ORDER BY 'Name'
...not return the value from the second sub-SELECT statement?
SELECT WFD_AttChoose3 AS WFD_AttChoose3, NULL
FROM WFElements
WHERE WFD_ID = 53584
Once I amend the entire query to omit the second column for each sub-SELECT statement query it works as expected, i.e. , [COS_JobTitle] AS [COS_JobTitle]
And , NULL
答案1
得分: 0
事实证明,一切都可以在一组不同的表格中运行。然而,并没有继续调查这个问题。
英文:
Turned out everything worked with a different set of tables. Did not follow through investigating that, though.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论