#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    1
    Rep Power
    0

    Run more than one select statement


    Hello,

    I am somewhat familiar with SQL. I have a website in which I need to update some rows (2000 of them) with different values. I have all the code ready, I had to break apart a excel database and came up with this code. I have searched everywhere and can't figure out to get this to work. When I run the code below I get this error

    MySQL returned an empty result set (i.e. zero rows).

    Any help would be great



    UPDATE `zen_products` SET `products_price`='99.98' WHERE `products_id` = 866080;
    UPDATE `zen_products` SET `products_price`='99.98' WHERE `products_id` = 866092;
    UPDATE `zen_products` SET `products_price`='99.98' WHERE `products_id` = 866117;
    UPDATE `zen_products` SET `products_price`='99.98' WHERE `products_id` = 866131;
    UPDATE `zen_products` SET `products_price`='99.98' WHERE `products_id` = 866155;
    UPDATE `zen_products` SET `products_price`='114.98' WHERE `products_id` = 866166;
    UPDATE `zen_products` SET `products_price`='114.98' WHERE `products_id` = 866167;
    UPDATE `zen_products` SET `products_price`='114.98' WHERE `products_id` = 866179;
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Mar 2008
    Posts
    1,928
    Rep Power
    378
    Code:
    Works for me...
    
    DROP TABLE IF EXISTS z_products;
    
    CREATE TABLE z_products (products_id INT NOT NULL PRIMARY KEY,products_price DECIMAL(5,2));
    
    INSERT INTO z_products (products_id) VALUES
    (866080),
    (866092),
    (866117),
    (866131),
    (866155),
    (866166),
    (866167),
    (866179);
    
    UPDATE `z_products` SET products_price = 99.98 WHERE products_id IN (866080,866092,866117,866131,866155); 
    UPDATE `z_products` SET products_price = 114.98 WHERE products_id IN (866166,866167,866179);
    
    SELECT * FROM z_products;
    +-------------+----------------+
    | products_id | products_price |
    +-------------+----------------+
    |      866080 |          99.98 |
    |      866092 |          99.98 |
    |      866117 |          99.98 |
    |      866131 |          99.98 |
    |      866155 |          99.98 |
    |      866166 |         114.98 |
    |      866167 |         114.98 |
    |      866179 |         114.98 |
    +-------------+----------------+
  4. #3
  5. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,147
    Rep Power
    4274
    Originally Posted by timhersh
    MySQL returned an empty result set (i.e. zero rows).
    updates don't actually return any rows

    think about it
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo