sqlite - 根据选择查询的输出连接表
问题描述
我尝试了以下但得到了错误的结果。
select tab_2.id_3,tab_2.name from tab_2 where tab_2.id_3 in (select id_1 from tab_1 where id_1= id_2)
我正在寻找的是:
我有第一个表,我在其中提取了我想要的 id:
tab_1:
id_1 | id_2
ab01 | ab01
ab02 | ab02
ab03 | ab05
ab04 | ab09
Select id_1 from tab_1 where id_1= id_2
--id_1--
ab01
ab02
tab_2
id_3|name
ab01|test
ab02|test
ab07|test
ab06|test
来自 tab_1 和 tab_2 的预期连接结果
id_1 | id_3 | name
ab01 | ab01 | test
ab02 | ab02 | test
谢谢你的帮助。
解决方案
解决了!
我遇到的问题是输出。在一个表中,ID 是大写的,而在第二个表中,ID 是小写的。所以我将其中一个转换为小写或大写。
下(ids)上(ids)
select tab_2.id_3,tab_2.name from tab_2 where tab_2.id_3 in (select id_1 from tab_1 where id_1= id_2)
推荐阅读
- javascript - Cypress ParseError:“import”和“export”可能只出现在“sourceType:module”中
- api - 微信 - 无法发送超过 1 条的富媒体消息
- javascript - Do while 和 Switch
- r - 如何在R中使用前一行(如excel)的公式计算结果
- reactjs - onSubmit 在 react 和 tsx 中的表单问题
- azure - 是否可以 dockerize Azure 云应用程序?
- c# - 使用 iOS 生成的公钥的 C# RSA 加密
- asp.net - Azure 诊断 Blob 存储中的 ASP.Net Core 2.1 日志布局
- ios - 处理 nIl?在 UITableViewCell
- php - 在 Laravel markdown 邮件中修改页脚