I have a table that displays data from a database, ordered by their category. For this I have a category field in the database, however now each item can now live under multiple categories (up to 3 max).
Is it possible to query the database once to look through all category rows and output one set of results? At the moment I am looking through category, outputting results, then loop through category2 then again for category3.
The categories are controlled in another table, hence the join below.
My table in the DB is like
id | category | category2 | category3 | productname | etc etc
Is it possible to query the database once to look through all category rows and output one set of results? At the moment I am looking through category, outputting results, then loop through category2 then again for category3.
The categories are controlled in another table, hence the join below.
Code:
SQL = "SELECT products.productid, products.productcategory, products.productname, productscategory.productcategory FROM products INNER JOIN productscategory ON products.productcategory=productscategory.id where products.removed is null order by products.productcategory"
set rs = server.CreateObject("ADODB.RECORDSET")
rs.open SQL,objConn
if not rs.EOF then
do while not rs.EOF
%>
<tr valign="top">
<td><%=rs("productcategory")%></td>
<td><%=rs("productname")%></td>
</tr>
//then again for category2.
My table in the DB is like
id | category | category2 | category3 | productname | etc etc