I'm currently at university and doing a project where I have queries such as:
Select * from recent_purchases where customer_id in
( select customer_id from
customers where name like '%john%'
)
I'm not sure if this is the most idiomatic way of doing things or if I'm missing the "correct" way of doing it - it certainly feels a bit clunky. I don't really understand joins yet. Sorry if a stupid question.
Use an INNER JOIN
instead of a Sub-Select in the WHERE
clause:
Select *
from recent_purchases rp
inner join customers c on c.customer_id = rp.customer_id
where c.name like '%john%'
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.