Query Pulling Wrong information from MySQL database :: Cactushop

This is a discussion on "Query Pulling Wrong information from MySQL database :: Cactushop" within the Classic ASP section. This forum, and the thread "Query Pulling Wrong information from MySQL database :: Cactushop are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 1st, 2007, 16:04
Up'n'Coming Member
Join Date: Jul 2007
Location: Barry
Age: 22
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Query Pulling Wrong information from MySQL database :: Cactushop

i have the following query

Code: Select all
strQuery = limitSQL("tblCactuShop" & TABLE_PREFIX & "Versions.V_Price, tblCactuShop" & TABLE_PREFIX & "Products.P_ID, tblCactuShop" & TABLE_PREFIX & "Products.P_DateAdded, tblCactuShop" & TABLE_PREFIX & "Categories.CAT_ID, tblCactuShop" & TABLE_PREFIX & "Products.P_Name" & numLanguageID & ", P_StrapLine" & CInt(numLanguageID) & " FROM (((tblCactuShop" & TABLE_PREFIX & "Versions INNER JOIN tblCactuShop" & TABLE_PREFIX & "Products ON tblCactuShop" & TABLE_PREFIX & "Versions.V_ProductID = tblCactuShop" & TABLE_PREFIX & "Products.P_ID) INNER JOIN tblCactuShop" & TABLE_PREFIX & "ProductCategoryLink ON tblCactuShop" & TABLE_PREFIX & "Products.P_ID = tblCactuShop" & TABLE_PREFIX & "ProductCategoryLink.PCAT_ProductID) INNER JOIN tblCactuShop" & TABLE_PREFIX & "Categories ON tblCactuShop" & TABLE_PREFIX & "ProductCategoryLink.PCAT_CategoryID = tblCactuShop" & TABLE_PREFIX & "Categories.CAT_ID) LEFT OUTER JOIN tblCactuShop" & TABLE_PREFIX & "Suppliers ON tblCactuShop" & TABLE_PREFIX & "Suppliers.SUP_ID WHERE P_Name" & CInt(numLanguageID)  & " <> '' AND V_Live ='y' AND P_Live = 'y' AND CAT_Live = 'y' AND V_CustomerGroupID IN (0," & DB_CG_ID & ") AND P_CustomerGroupID IN (0," & DB_CG_ID & ") AND CAT_CustomerGroupID IN (0," & DB_CG_ID & ") AND (SUP_Live <> 'n' OR SUP_Live IS NULL) AND P_Featured=0 ORDER BY P_ID DESC", numNewestProductsList, true)
but if i have a product with 2 version and both are different prices it pulls out both the versions. in a select query in one of the other pages it has this query

Code: Select all
strQuery = "SELECT " & strDistinctRowStatement & " " & strSelectValues & ", MIN(V_Price) As MinPrice, MIN(T_TaxRate) As MinTaxRate FROM ((((tblCactuShop" & TABLE_PREFIX & "Categories c INNER JOIN tblCactuShop" & TABLE_PREFIX & "ProductCategoryLink pcl ON c.CAT_ID = pcl.PCAT_CategoryID) INNER JOIN tblCactuShop" & TABLE_PREFIX & "Products ON pcl.PCAT_ProductID = tblCactuShop" & TABLE_PREFIX & "Products.P_ID) INNER JOIN tblCactuShop" & TABLE_PREFIX & "Versions v ON tblCactuShop" & TABLE_PREFIX & "Products.P_ID = v.V_ProductID) INNER JOIN tblCactuShop" & TABLE_PREFIX & "TaxRates t on v.V_Tax = t.T_ID) LEFT OUTER JOIN tblCactuShop" & TABLE_PREFIX & "Suppliers s ON tblCactuShop" & TABLE_PREFIX & "Products.P_SupplierID = s.SUP_ID WHERE P_Name" & CInt(numLanguageID)  & " <> '' AND V_Live = 'y' AND V_CustomerGroupID IN (0," & NumSafe(DB_CG_ID) & ") AND P_Live = 'y' AND NOT (P_End = 'y' AND V_Quantity < 1) AND P_CustomerGroupID IN (0," & NumSafe(DB_CG_ID) & ") AND CAT_Live = 'y' AND CAT_CustomerGroupID IN (0," & NumSafe(DB_CG_ID) & ") AND CAT_ID=" & CAT_ID & " AND (SUP_Live <> 'n' OR SUP_Live IS NULL) GROUP BY " & strSelectValues2 & " ORDER BY " & strProductsOrderBy
which pulls out the minimum priced version only how would i get my query to only pull out the lowest price version like the above select does?

Last edited by Rob; Oct 3rd, 2007 at 13:40.
Reply With Quote

  #2 (permalink)  
Old Oct 3rd, 2007, 11:06
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
Re: Query Pulling Wrong information from MySQL database :: Cactushop

basically cactushop products can have multiple versions, with different prices (e.g. different models of iPOD or whatever) .... but when listing products, it shows 'from $XXX', pulling out lowest price to display

Is that not the behaviour you want?

Can you please give me some more info as I am pretty confused about what behaviour you are trying to change.

If it helps, this bit in the second query does the min pricing bit
Code: Select all
strQuery = "SELECT " & strDistinctRowStatement & " " & strSelectValues & ", MIN(V_Price) As MinPrice, MIN(T_TaxRate) As MinTaxRate
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Basic database to call information hausjellp PHP Forum 30 May 1st, 2008 09:29
CactuShop query B3ndy Classic ASP 1 Nov 5th, 2007 03:12
query whole of database saltedm8 PHP Forum 1 May 9th, 2007 12:50
MySQL query query dangergeek Databases 3 Apr 12th, 2007 12:45
Database Design Query gustava32 Databases 4 Nov 6th, 2006 15:30


All times are GMT. The time now is 21:02.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43