Note that there are some explanatory texts on larger screens.

plurals
  1. POsql/Mysql: What is the best method to complete this query
    text
    copied!<p>I had most of this query worked about except two things, large things, one, as soon as I add the forth table [<strong>departments_tbl</strong>]into the query, I get about 8K rows returned when I should only have about 100.</p> <p>See the attached schema, no the checkmarks, these are the fields I want returned.</p> <p>This won't help, but here is just one of the queries that I almost had working, until the [department_tbl was added to the mix]</p> <pre><code>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 </code></pre> <p>I've tried subqueries, joins, but just can't get it to work.</p> <p>Any help would be greatly appreciated.</p> <p>Schema <strong>Please</strong> note that <strong>entity_id</strong> and <strong>cust_id</strong> fields would the be links between the <strong>_ncust_rpt_copy table</strong> and <strong>the _n_cust_entity_storeid_15 tbl</strong> <img src="https://i.stack.imgur.com/5v1y5.png" alt="enter image description here"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload