簡體   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