[ic] How can I nest loops or queries?

chaim klar hershey135@hotmail.com
Sun, 25 Feb 2001 17:59:15

How can I nest loops or queries?
I have two tables  the first table called products looks like this:
p_sku	price	...,
C2100Z	14.50
C211Z	45.35
KF800	63.98
KW	51.21
KFP	45.92
KFW	51.62
...	....

Then another table called accessories that looks like this:
AutoNumber      a_code  accessory
1       KF800   C2100Z
2       KF800   C211Z
3       KF800   KW
4       KF800   KFP
5       KF800   KFW
6       C2100Z  MBSM
7       C2100Z  16MBSM
8       C2100Z  32MBSM
9       C2100Z  64MBSM
10      C2100Z  B28

(a_code may exist a few for each item in the products table)

So in the flypage.html I first look up in the accessories table with the 
item to see if it has  accessories (and to convince myself that it indeed 
accessories for the current item I first display them) and then with the 
I make another loop in the products table to get the price and description 
for the
accessories like this:

[loop prefix=outer 

	[outer-data accessories a_code][outer-data accessories accessory]

	[loop prefix=inner search="fi=products/se[outer-data accessories 
		[inner-data products p_sku][inner-data products price]


but for some reason I get the accessories to display before entering the 
second loop but not
after the second loop so I have tired doing it with [query] like this:


                            SELECT p_sku
                            FROM products
                            WHERE p_sku IN (
                                            SELECT accessory
                                            FROM accessories
                                            WHERE a_code = 'KF800'
    [sql-increment]) [sql-param p_sku]<br>

but I didn't get better results.

Thanking You in advance.

Chaim Klar
Get your FREE download of MSN Explorer at http://explorer.msn.com