Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to retrieve values from two tables in my PHPMyAdmin database.

I am not great with MySQL, and tried the query below to no avail.


I need to retrieve the Products ID and Price from the Products table, and the Product Options Values Name from the Products Options Values table.


There is no direct link between the two tables, and so I tried retrieving the values linking through different tables, however this is obviously incorrect.


SQL
SELECT p.products_id, p.products_price, o.products_options_values_name

FROM products p, products_options_values o

WHERE p.products_id = products_attributes.products_id

AND products_attributes.options_id = products_options_values_to_products_options.products_options_id

AND products_options_values_to_products_options.products_options_values_id = o.products_options_values_id

ORDER BY `products_id` ASC




Any help would be great. Thanks
Posted
Comments
Patel Shailendra 10-Dec-12 22:06pm    
Can you paste you table structure with sum dummy contain.

1 solution

select p.ProductsID,P.Price from Products as p inner join Products Options Values as Po on p.ProductsID=po.ProductsID
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900