0

ecommerce website ASP coded using MS SQL:

product page - display product with all atributes.
|----> on product page display associated products.
|
|----> Optional products are pulled from the database via a table with two columns, one column for each linked product.

So on the product page it looks at this table to see if any products are associated with it and displays it.


In the shopping cart, it does the same thing, it displays the associated prdocuts. If there is more than one product in the shopping cart, I set the first loop to loop through the products in the cart (one table in the DB), and within that loop I loop again to pull each associated product (from the associated product table in the DB).

My issue is: Some products in the shopping cart will end up have the same associated products and end up displaying the same associated product, in other words the same item will be shown more than once. How do I limit the script to only display an associated product once?

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by SheSaidImaPregy
0

Depends on how your database is set up, but you could add "DISTINCT" to your SQL query. By this, it only grabs unique names.

"SELECT DISTINCT productname FROM blablah"


Otherwise, you should do a grab on both tables at once, then loop through and put into two columns.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.