这个查询的大部分工作除了两件事,一件大事,一个,只要我将第四个表[部门_tbl ]添加到查询中,我就会得到大约 8K 行,而我应该只有大约 100 行。
请参阅附加的架构,没有复选标记,这些是我想要返回的字段。
这无济于事,但这只是我几乎一直在工作的查询之一,直到 [department_tbl 被添加到组合中]
SELECT _n_cust_entity_storeid_15.entity_id,
_n_cust_entity_storeid_15.email,
customer_group.customer_group_code,
departments.`name`,
departments.manager,
_n_cust_rpt_copy.first_name,
_n_cust_rpt_copy.last_name,
_n_cust_rpt_copy.last_login_date,
_n_cust_rpt_copy.billing_address,
_n_cust_rpt_copy.billing_city,
_n_cust_rpt_copy.billing_state,
_n_cust_rpt_copy.billing_zip
FROM _n_cust_entity_storeid_15 INNER JOIN customer_group ON _n_cust_entity_storeid_15.group_id = customer_group.customer_group_id
INNER JOIN departments ON _n_cust_entity_storeid_15.store_id = departments.store_id,
_n_cust_rpt_copy
ORDER BY _n_cust_rpt_copy.last_name ASC
我已经尝试过子查询、连接,但无法让它工作。
任何帮助将不胜感激。
Schema 请注意entity_id和cust_id字段将是_ncust_rpt_copy 表和_n_cust_entity_storeid_15 tbl之间的链接