Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2002
    Thanked 0 Times in 0 Posts

    select to id's from 3 tables?

    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.

  2. #2
    Senior Coder
    Join Date
    Jun 2002
    41 8' 52" N -95 53' 31" W
    Thanked 0 Times in 0 Posts
    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.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts