I have two SQL2005 tables:
-
Table 1: LandingPages
-
Table 2: Products
The LandingPages table manages the heading, description and other details that are displayed on each of about 200 targetted landing pages. Each record also has a set of default Criteria fields that specify what products should be shown on each individual landing page.
So, a landing page about widgets with red tops and blue bottoms would have a record thus:
- LPID: 1
- Title: Widgets with Red Tops and Blue Bottoms
- Product Category: Widget
- Top: Red
- Bottom: Blue
Each landing page record has a unique ID, called LPID.
I want a stored procedure that takes the LPID, reads the criteria and then returns a recordset of matching products.
What is the best way to achieve this for performance?
I have tried reading the various criteria into lots of variables, then doing a select using the variables in the WHERE of the SELECT.
I am trying to see if a CTE can be used / is better than my current method, but I'm not sure I can use the CTE within the WHERE of my SELECT.
-- Extra note: certain options can be changed by the user, such as maximum price and sorting.
Can anyone help? Thanks.
Aucun commentaire:
Enregistrer un commentaire