繁体   English   中英

根据表A选定的列从表B中选择一列

[英]Select a column from table B based on table A selected column

我正在尝试执行以下操作。

Table A
Name ID

Table B
ID Remark

根据表A名称选择表B注释。

使用名称在表A中获取ID,然后在表B中匹配ID以从表B获取备注。

请问这可能吗?

您可以在存在的地方使用

select remark from tableB b where exists (select 1 from tableA a where a.name= [give_name] and a.id=b.id); 

select remark from tableB b where b.id in (select id from tableA where name = [give_name]);

您可以使用JOIN

SELECT remark FROM tableB b
JOIN tableA a ON a.ID = b.ID 
WHERE a.name = ?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM