Jump to content

A suggested SQL Statement to make this to work!


prichardson

Recommended Posts

What SQL Statement should I write to get this desired result:- A drop down list that dynamically displays the (numerous) "product sizes" of a product from a table.At the moment, I have a table "products" that has "product name" and "product sizes". There will be many products that have different sizes. For example. I would have 3 entries in the table, each have the same name, but different sizes. So when user clicks on the drop down list of a product it would display the 3 different sizes. Then when the user has clicked on the size of the product- it to go to that product page which would have more information on that product.Can anyone help me on what code I should write for the SQL statement? Many Thanks

Link to comment
Share on other sites

I would probably set it up with two tables: Products and ProductSizes.Products: ProductID ProductName ProductDescriptionProductSizes: ProductID ProductWidth ProductHeight ProductDepth ProductWeight ... you get the idea ...Then, you would have one entry for each product in your Products table and you could have as many Sizes for each product that you needed in the ProductSizes table. The query to get the sizes in this situation would be something like:

SELECT * FROM ProductSizes WHERE ProductID = 345;

Otherwise, to answer the question for your current setup, the query could look something like this:

SELECT * FROM products WHERE productname LIKE 'Some Product Name';

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...