Welcome Guest, Not a member yet? Register   Sign In
Nested Query Question (NEWBIE)
#12

[eluser]JesseR[/eluser]
Yes it is great exercise. I will definently read up on implement iterator.

Also I am going to see what I can do to the database. Since I am using
database from an existing business system I was stuck with its logic
of tables and fields. However I am basically copying the existing
database from its original source of a SQL database to a mySql db
just for the use of this script. So I can make changes to my new copy
of the database basically by writing some queires that run automatically
and place the price in the same table as items, and do a majority of
my logic possibly.

A new challenge I have is this. I have an item that comes in
numerous colors if ITEMS.MATRIX_ITEM_TYPE = 'x' then I need
to show each color as an item on the product page. The below
query accomplishes this but of course I want this set of items
to display in correct order with my other items in the same category.
I might have five items that have five color options and then 20
items in the same category that have no color options.

What would you suggest to accomplish this?

Code:
SELECT
                    ITEMS.CUSTNUM1 AS ITEM_RANK, ITEMS.ITEMNO AS ITEM_NO, CONCAT(ITEMS.DESCRIPT,' ',MATRIX_ATTRIBUTE_ELEMENTS.ELEMENT_DESCRIPTION) AS ITEM_NAME,
                    CONCAT(ITEMS.ITEMNO,'-',MATRIX_ELEMENT_SELECTION.ELEMENT_CODE,'.jpg') AS ITEM_IMAGE, ITEMS.CATEGORY AS ITEM_CATEGORY, ITEMS.MATRIX_ITEM_TYPE AS ITEM_MATRIX_ITEM_TYPE, ITEMS.QTY_STK AS ITEM_STOCK, CATEGORY.CUSTCHAR2 AS CATEGORY_FOLDER, CREAT_DATE AS ITEM_CREATE_DATE,MANUCODE AS ITEM_MANUCODE,BRAND AS ITEM_BRAND,MATRIX_ATTRIBUTE_ELEMENTS.ELEMENT_DESCRIPTION AS ITEM_COLOR,MATRIX_ATTRIBUTE_ELEMENTS.ELEMENT_CODE  AS ITEM_IMAGE_COLOR
                    FROM ITEMS

INNER JOIN MATRIX_ELEMENT_SELECTION ON ITEMS.ITEMNO  = MATRIX_ELEMENT_SELECTION.MATRIX_GROUP_CODE AND MATRIX_ELEMENT_SELECTION.ATTRIBUTE_DESCRIPTION = 'Sanita Color'
INNER JOIN MATRIX_ATTRIBUTE_ELEMENTS ON MATRIX_ELEMENT_SELECTION.ELEMENT_CODE = MATRIX_ATTRIBUTE_ELEMENTS.ELEMENT_CODE AND MATRIX_ATTRIBUTE_ELEMENTS.ATTRIBUTE_DESCRIPTION = MATRIX_ELEMENT_SELECTION.ATTRIBUTE_DESCRIPTION
INNER JOIN CATEGORY ON ITEMS.CATEGORY= CATEGORY.CATEGORY
WHERE ITEMS.CATEGORY = '$c'


Messages In This Thread
Nested Query Question (NEWBIE) - by El Forum - 01-13-2010, 03:49 PM
Nested Query Question (NEWBIE) - by El Forum - 01-13-2010, 04:38 PM
Nested Query Question (NEWBIE) - by El Forum - 01-13-2010, 04:55 PM
Nested Query Question (NEWBIE) - by El Forum - 01-13-2010, 05:26 PM
Nested Query Question (NEWBIE) - by El Forum - 01-13-2010, 11:05 PM
Nested Query Question (NEWBIE) - by El Forum - 01-14-2010, 03:35 AM
Nested Query Question (NEWBIE) - by El Forum - 01-14-2010, 07:12 AM
Nested Query Question (NEWBIE) - by El Forum - 01-14-2010, 08:42 AM
Nested Query Question (NEWBIE) - by El Forum - 01-14-2010, 12:08 PM
Nested Query Question (NEWBIE) - by El Forum - 01-14-2010, 03:08 PM
Nested Query Question (NEWBIE) - by El Forum - 01-15-2010, 03:15 AM
Nested Query Question (NEWBIE) - by El Forum - 01-15-2010, 07:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB