Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Posts
    1

    Unanswered: Unable to Update Using Inner Join

    I'm trying to update 1 table using a join to link data from another table:

    Table 1: products

    products_id int(5)
    products_quantity int(4)
    products_model varchar(12)
    products_image varchar(64)
    products_mediumimage varchar(64)
    products_largeimage varchar(64)
    products_price decimal(15,4)
    products_date_products_weight decimal(5,2)
    products_status tinyint(1)
    products_tax_class_id int(5)
    manufacturers_id int(5)
    products_date_available datetime
    products_last_modified datetime
    products_ordered int(11)


    Table 2: products_to_categories

    products_id int(5)
    products_id int(5)


    Failing SQL Statement:

    update products
    inner join products_to_categories on
    products_to_categories.products_id = products.products_id
    set products.products_image = 'CS-D9.jpg'
    where products_to_categories.categories_id = 63;

    Error:

    You have an error in your SQL syntax near 'INNER JOIN products_to_categories ON products_to_categories.products_id = produ' at line 1

  2. #2
    Join Date
    May 2002
    Location
    Vancouver Canada
    Posts
    26
    I don't think you can do joins in updates with MySQL yet

  3. #3
    Join Date
    Apr 2003
    Location
    Norway
    Posts
    5

    Wink

    Try this:

    update products
    set products.products_image = 'CS-D9.jpg'
    from products inner join products_to_categories on
    products_to_categories.products_id = products.products_id
    where products_to_categories.categories_id = 63;

Posting Permissions

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