Jump to content

different stock values to different product attributes


ridingwave

Recommended Posts

Hi,

 

My name is Tiago and I'm from Portugal.

 

 

I've posted this question in a lot of forums but unfortunately still don't have an answer...

 

I'm using "The MySQL Database Admin v1.5.5", which is installed in my host's control panel.

 

I'm developing a webstore, and I want to create the possibility of associating different stock values to different product attributes.

 

Example:

 

I have two t-shirts of the model A, one in green and one in white. As it is today, I can only assign a total stock ammount of 2 items (white + green).

 

I want to have the possibility of associating a stock value for the model A white t-shirt, and another stock value to model A green t-shirt.

 

I already have a Products table on my Mysql database. On it there's an Attributes field. It also has a Stock field (it's working but only like a total stock, not a stock for each feature). So I can set different features to the same product.

 

Now what I need is a table that tells me that I can have different stock values (product quantities) for different attributes of the same product.

 

I'd be very thankfull if you could help me on this.

 

Thanks in advance.

 

Kind regards,

Link to comment
Share on other sites

you could try a structure like this

[pre]

producr          subproduct

=========        ==============

prodID      --+  subprodID

description  +-- prodID

                  description

                  stock_qty

                 

DATA

product                            subproduct

 

123  |  T-Shirt A                  1  |  123  |  green          |  5

                                    2  |  123  |  white          | 20

Link to comment
Share on other sites

This is what I did already:

 

Created table subproduct, which contains fields ID, subproductID, productID, description and stock.

 

Now I didn't understand your query very well...

 

You have some abreviations that I don't understand...

 

Sorry this is all new to me yet...

Link to comment
Share on other sites

ok so this is what i did:

 

SELECT fws_product.productID, fws_product.description, fws_subproduct.description, fws_subproduct.stock
FROM fws.product
    INNER JOIN fws_subproduct ON fws_product.productID = fws_subproduct.productID

 

i got this error:

 

SQL query: Documentation

 

SELECT fws_product.productID, fws_product.description, fws_subproduct.description, fws_subproduct.stock

FROM fws.product

INNER JOIN fws_subproduct ON fws_product.productID = fws_subproduct.productID

LIMIT 0 , 30

 

MySQL said: Documentation

#1142 - SELECT command denied to user 'riding'@'localhost' for table 'product'

 

 

 

what i did wrong?

 

 

Link to comment
Share on other sites

i renamed description of subproduct to "subdescription" is that ok now?

 

then I inserted this code :

 

SELECT fws_product.productID, fws_product.description, fws_subproduct.subdescription, fws_subproduct.stock
FROM fws_product
    LEFT JOIN fws_subproduct ON fws_product.productID = fws_subproduct.productID

 

and got this as a result :

 

innerjoinhi3.jpg

 

I guess I'm getting to what I need but on the website 'm still not getting any option to insert the subproduct info...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.