我在cust_vend_relation
但它被展示了两次。
select cvr.customer_id,
cvr.address_label,
cvr.vendor_name,
cvr.vendor_id,
vhd.locality,
vhd.area,
vhd.address,
vhd.city,
vhd.state
from cust_vend_relation cvr, vendor_home_delivery vhd
where cvr.vendor_id = vhd.vendor_id
and cvr.address_label = 'Office'
and cvr.customer_id = 3;
我只需要显示表cust_vend_relation
下的记录,这些记录与vendor_home_delivery
下的记录相匹配。
任何人都可以帮助我。
答案 0 :(得分:0)
按customer_id添加分组
select
cvr.customer_id,
cvr.address_label,
cvr.vendor_name,
cvr.vendor_id,
vhd.locality,
vhd.area,
vhd.address,
vhd.city,
vhd.state
from cust_vend_relation cvr, vendor_home_delivery vhd
where cvr.vendor_id = vhd.vendor_id and cvr.address_label = 'Office' and cvr.customer_id = 3 group by customer_id;