【发布时间】:2017-01-28 01:28:29
【问题描述】:
假设我有两个分区表,分别是 customer 和 items,它们都由 country 和 state 列分区。
鉴于我想检索特定国家和州的数据,这是加入这些表格内容的正确方法吗?
select
customer.id,
customer.name,
items.name,
items.value
from
customers
join items
on customers.id == items.customer_id
and customers.country == 'USA'
and customers.state == 'TX'
and items.country == 'USA'
and items.state == 'TX'
或者这些条件应该放在 WHERE 子句中吗?
and customers.country == 'USA'
and customers.state == 'TX'
and items.country == 'USA'
and items.state == 'TX'
【问题讨论】:
-
这些条件应该放在 WHERE 子句中。