【发布时间】:2021-04-17 06:09:54
【问题描述】:
我试过这个:
select *
from table2
where exists (
select *
from table1
where table2.column1 = table1.column1
)
输出:它返回 table2 中列的所有表头,但不返回任何记录。
观察:当我尝试匹配值间列时,它正在返回记录。但它在匹配字符值列时不起作用
注意:table1 和 table2 中的 column1 都有字符值。
select [Data Name]
from [DynamicDataTable]
where exists (
select *
from University_Temp
where DynamicDataTable.autocode = University_Temp.autocode
)
上述查询的输出
[Data Name]
Title
First Name
Geebee Centre
Country of Permanent Residence
SSC Institute/College
上述查询返回匹配的自动代码记录,数据类型为整数。
【问题讨论】:
-
你能试试运行这段代码
select * from table2, table1 where table2.column1=table1.column1;吗?它输出任何记录吗? -
您能否也发布您提到的代码在您的问题中有效(匹配值间列)?
-
请编辑您的问题并将任何相关信息放在问题中,而不是在 cmets 中。您可以编辑您的问题here
-
发布有效的查询无法帮助我们帮助您解决无效的查询。发布示例数据并发布您想要的结果。
-
我们需要查看查询失败的数据。请发布示例数据
标签: sql sql-server database