Page 1 of 1

Inventory/Stock Tracking

Posted: Sun Dec 03, 2006 4:53 pm
by Mr Tech
I have created a shopping cart script and am wanting to add a Inventory/Stock Tracking script that notifies the admin when they are low on stock... This would normally be easy however I have set-up the script so that you can add "options" to your products. Options could be anything such as size, colour, make etc... Because there are options, I need tot rack the stock of each option combination.

The product name is:

Shoes

And has these size options:

Small
Medium
Large


And these color options:

Red
Blue
Green


The above options would need to be put into a list like this... I could then have a text box at the end of each line where you would enetr how much stock is left.

Shoes Small Red
Shoes Small Blue
Shoes Small Green
Shoes Medium Red
Shoes Medium Blue
Shoes Medium Green
Shoes Large Red
Shoes Large Blue
Shoes Large Green


Now for my question.

How would I select all those different options from the database and put them in the list like above without having duplicates? What I mean by duplicates is the list would end up like this:

Shoes Small Red
Shoes Small Blue
Shoes Small Green
Shoes Medium Red
Shoes Medium Blue
Shoes Medium Green
Shoes Large Red
Shoes Large Blue
Shoes Large Green
Shoes Red Small
Shoes Red Medium
Shoes Red Large
Shoes Blue Small
Shoes Blue Large
Shoes Blue Medium
Shoes Green Small
Shoes Green Medium
Shoes Green Large


Only having the two options (Size and Color) makes it a little easier but if you had 3, 4 or even 6 options, it would get a little more complicated.

Hopefully I'm making sense.

Posted: Sun Dec 03, 2006 5:51 pm
by feyd

Code: Select all

SELECT foo1, foo2, foo3 FROM table1 WHERE foo1 IN('option1', 'option2', 'option3') AND foo2 IN('option4','option5','option6') .....
something like that, if I understand your question.

Posted: Sun Dec 03, 2006 5:57 pm
by Mr Tech
Where can I find more info about the IN function from your query? two letter words don't get searched for in Google...

Posted: Sun Dec 03, 2006 6:47 pm
by feyd
I couldn't remember where it was stuck in the documentation for a bit, but I found it.

http://dev.mysql.com/doc/refman/5.0/en/ ... #id2810044