Jump to content

Archived

This topic is now archived and is closed to further replies.

criticman

** SOLVED ** Interesting MySQL SELECT query issue

Recommended Posts

[!--sizeo:5--][span style=\"font-size:18pt;line-height:100%\"][!--/sizeo--][!--fonto:Arial Black--][span style=\"font-family:Arial Black\"][!--/fonto--]SOLVED - Thanks[!--fontc--][/span][!--/fontc--][!--sizec--][/span][!--/sizec--]

 

So I am working on a project for a company doing an online e-commerce site with a full product catalog.

 

I had things going just fine until they put some interesting requirements on me. This required restructuring of the MySQL table.

 

So, I now have an issue. I am working on the "browse products" page. I have no issue displaying categories, then subcategories, then listing all items under them. The issue is there are several item #'s for each set of item.

 

Items have different sizes, and unfortunately each size has its own item number.

 

I.E.

ONG76515-XL, ONG76515-L, ONG76515-S, ONG76515-M

 

What the client now wants (contrary to original request and I do not have time to redo the MySQL tables) is to only display ONE item number on the browse page per set of similar item #'s (basically, show size S and hide sizes M, L, XL until you get to the product detail page).

 

So, right now my query is thus:

 

SELECT * FROM ProductList WHERE cat = '$cat' AND subcat = '$subcat' ORDER BY brand, prodName, details ASC

 

Is there a somewhat efficient way to go about doing this within the SQL query? I would like it to be optimized to the query so that I am not creating tons of overhead by loading 100's of item #s and then hiding all but one per item # set using PHP.

 

Any help is more than appreciated. I am just stumped and in need of sleep. Project is due Monday AM.

Share this post


Link to post
Share on other sites

[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] * FROM ProductList WHERE cat = '$cat' AND subcat = '$subcat' AND RIGHT(itemNumber,1)='S' ORDER BY brand, prodName, details ASC [!--sql2--][/div][!--sql3--]

Share this post


Link to post
Share on other sites

[!--quoteo(post=318395:date=Nov 14 2005, 12:13 PM:name=ryanlwh)--][div class=\'quotetop\']QUOTE(ryanlwh @ Nov 14 2005, 12:13 PM) 318395[/snapback][/div][div class=\'quotemain\'][!--quotec--]

[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] * FROM ProductList WHERE cat = '$cat' AND subcat = '$subcat' AND RIGHT(itemNumber,1)='S' ORDER BY brand, prodName, details ASC [!--sql2--][/div][!--sql3--]

 

Thanks. I posted this on several forums, same response on all. Not all item numbers follow that format, so I will have to restructure the table when I have the time. For now they will have to deal with what I have given them.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.