View Full Version : select to id's from 3 tables?

11-17-2002, 06:43 PM
Ok, I can't get this to work. I have 3 tables I need to reference, products, products_description and products_to_categories. I'm trying to select the name and price for all products in category 45. products_id is link id. The name is in products_description and the price is in products. Products_to_categories has products_id and categories_id. Here's what I'm using:

SELECT products_name, products_price FROM products_description, products, products_to_categories join products_description, products on products_id and join products_to_categories to products_description on products_id where products_to_categories.categories_id = 45

It obviously doesn't work. Can anyone see where I went wrong? Specifically I'm getting an erroer that products_description is not unique, possibly because I have prodcuts_description field within the products_description table. TIA.

11-18-2002, 05:40 AM
It's generally not a good idea to name a field the same thing as your table. Perhaps using [] around your field name in the SQL statement, or using dbo.Tablename will help. :)