Note that there are some explanatory texts on larger screens.

plurals
  1. PODrilling Down the Data ColdFusion
    primarykey
    data
    text
    <p>I am having trouble with drilling down some data, this is the table structure</p> <p><strong>Products Table</strong> </p> <p>uid_product (unique id)</p> <p>txt_prod_name (product name)</p> <p>Table Name: tbl_products</p> <p><strong>Product Features</strong></p> <p>uid_feature(unique id)</p> <p>txt_feature_name(feature name)Table Name: tbl_features</p> <p><strong>Assigned Product Features</strong></p> <p>uid_prodf (unique id)</p> <p>uid_prodf_prodid (foreign key to uid_product)</p> <p>uid_prodf_featid(foreign key to the uid_features)</p> <p>Table Name: tbl_prod_features</p> <p>One product can have many features hence the use of the tbl_prod_features table. </p> <p>I have created the following query, to obtain the results;</p> <pre><code>&lt;cfquery name="getFeatureProducts" datasource="#application.dsn#"&gt; SELECT uid_product, txt_prod_name FROM dbo.tbl_products WHERE uid_product IN (SELECT (dbo.tbl_product_features.uid_prodf_prodid) FROM dbo.tbl_product_features WHERE uid_prodf_featid IN (&lt;cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#arguments.uid_features#" list="yes"&gt;)) ORDER BY dbo.tbl_products.txt_prod_name &lt;/cfquery&gt; </code></pre> <p>This works great for getting all products associated to the features selected by the end user. However what I need to achieve is the following,</p> <p>If a user selects;</p> <p><strong>Feature A</strong> = 5 products displayed (3 out of 5 of these products contains Feature B)</p> <p>If the user then selects;</p> <p><strong>Feature B</strong> = 3 Products</p> <p>Currently with the query using the in operator it will still retrieve 5 products.</p> <p>My first thoughts was to create a dynamic where statement adding the AND operator, however uid_prodf_featid = 5 AND uid_prodf_featid = 6 will always produce 0 results.</p> <p>My second idea was to build an array of product id’s from the first drill down i.e. get the id’s of the first 5 products, and pass them in to the query and then drill down the features, this works and the correct results are obtained. </p> <p>However the user has the ability to remove features (and in any order), so I would somehow need to keep track of the products id’s as and when they were added and removed.</p> <p>I am sure I am overcomplicating this, but any help would be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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