www.webdeveloper.com
Results 1 to 3 of 3

Thread: MySQL update query involving two tables is not working, ...really stumped!

  1. #1
    Join Date
    Mar 2010
    Posts
    281

    MySQL update query involving two tables is not working, ...really stumped!

    i'm really stumped why this SQL statement is not working. I guess my MySQL has gotten rusty.

    PHP Code:
    UPDATE mscanproducts SET mscanproducts.manufacturers_id 37 where 
    mscanproducts
    .products_id mscanproducts_to_categories.products_id and mscanproducts_to_categories.categories_id 5
    The error i'm getting is this.
    PHP Code:
    Unknown column 'mscanproducts_to_categories.products_id' in 'where clause' 
    but i'm sure the column and table do exist

    i'll try to briefly to describe the tables

    mscanproducts:
    products_id | manufactures_id
    1 | null

    mscanproducts_to_categories
    products_id | categories_id
    1 | 5
    Last edited by toptomato; 01-23-2014 at 03:13 PM.

  2. #2
    Join Date
    Mar 2010
    Posts
    281
    Correction, that is NOT working.

    UPDATE mscanproducts SET manufacturers_id = 37 where products_id = (select products_id from mscanproducts_to_categories where categories_id = 5);

    the error i'm getting is

    #1242 - Subquery returns more than 1 row

    which is what i want, i want more than 1 row updated,... hmmmmmm

    ??
    Last edited by toptomato; 01-23-2014 at 03:35 PM.

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,175
    Code:
    ... where products_id IN (select ...
    ?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles