![](/img/trans.png)
[英]MYSQL SELECT WHERE Clause : How to include a column from another table?
[英]How to query a MySql table with a where clause from another table?
我在 MySql 數據庫中有兩個表,一個稱為銷售,一個稱為拍賣。 sales 表有一個auction_id 列。 我想提取僅以歐元進行的銷售額,但貨幣是拍賣表中的一列。 我應該運行什么查詢來實現這一目標? 非常感謝
您可以使用內部查詢執行此操作
select *
from sales
where auction_id in (select id from auctions where currency='EUR');
它會做什么
也可以使用其他選項來使用 join
SELECT *
FROM sales, auctions
WHERE sales.auction_id = auctions.id AND auctions.currency='EUR'
或者
SELECT *
FROM sales
JOIN auctions ON sales.auction_id = auctions.id AND auctions.currency='EUR'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.