I have two tables in a MySql database, one called sales and one called auctions. The sales table has an auction_id column. I want to extract sales which were only made in EUR, but the currency is a column in the auctions table. What query should I run to achieve this? Many thanks
You can do this using inner query
select *
from sales
where auction_id in (select id from auctions where currency='EUR');
what it will do
Other option is also available that is using join
SELECT *
FROM sales, auctions
WHERE sales.auction_id = auctions.id AND auctions.currency='EUR'
OR
SELECT *
FROM sales
JOIN auctions ON sales.auction_id = auctions.id AND auctions.currency='EUR'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.