sql - 将table1中的column1与table2中的column1匹配,并返回table2中与table1的column1匹配的*记录
问题描述
我试过这个:
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
上面的查询返回匹配自动代码的记录,这些记录是数据类型的整数。
解决方案
因此,您想查看table2
whereColumn1
与Column1
from匹配的所有行table1
?
如果我理解正确,这只是一个简单的加入
select t2.*
from table2 t2
inner join table1 t1 on t2.Column1 = t1.Column1
如果这不是您想要的,请编辑您的问题并更详细地解释您需要什么
推荐阅读
- powershell - 使用 PowerShell 在远程机器上执行命令
- java - CGLIB 如何代理 String 或其他 final 类?
- javascript - 如何将文件下载到本地机器而不是量角器中的网格节点
- .net - MSBuild DeployOnBuild=true 忽略 C# WCF 服务到文件共享
- javascript - 为什么 x 在下面的程序中没有被删除?
- python - Pandas:从 s3 访问文件的最有效方式
- ios - 如何将 .txt 文件的一部分加载到 textview 上以消除滞后现象
- spring-boot - 无法为功能区和 hyxtrix 设置超时
- html - 在 Bootstrap 4 中,“.navbar-toggler”按钮不会向右浮动
- java - 硬件和 AVD 模拟器之间的分辨率差异