Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    Mar 2014
    Location
    Australia
    Posts
    2
    Plugin Contributions
    0

    Default Need an SQL query to select a range of products and update the product status to 0

    Hi all,

    Long time lurker here and Zencart user since 2010 but first ever post, as I've always been able to find what I needed to know by reading the forums, and the responses from the very helpful people here

    However this one has me stumped. My situation is:

    Zencart 1.51 with around 2,000 products (books)

    I haven't updated the DB for a while and after doing some housekeeping I found that 400 of these books are now out of print, hence I want to disable them from showing but keep them in the database - in other words, set product_status to 0.

    I've had a play around in MySQL attempting to get this to work, but don't seem to be able to get the syntax right.

    I've created a new table with all the out of print products with just the ISBN (equivalent to products_model in my DB) as the key, and done an inner join on the DB products table against the "out of print" products table.

    That's all fine and I now have a select list of 400 matching products. For the life of my I cannot work out how to then update the DB products table to set these selected products to products_status=0...

    I know there are tools like EZ Populate which I believe would do the job but I think this is a relatively simple update to do, once I know the correct syntax


    Thanks all!

  2. #2
    Join Date
    Mar 2014
    Location
    Australia
    Posts
    2
    Plugin Contributions
    0

    Default Re: Need an SQL query to select a range of products and update the product status to

    Murphy's Law said that I would find the answer 10 minutes after I posted the question...

    UPDATE products
    INNER JOIN
    books_out_of_print
    ON products.products_model = books_out_of_print.isbn
    SET products.products_status = 0

    Query OK, 398 rows affected (1.45 sec)


    Thanks all - hopefully this may help someone else in the same situation!

    Cheers

  3. #3
    Join Date
    Jul 2012
    Posts
    16,816
    Plugin Contributions
    17

    Default Re: Need an SQL query to select a range of products and update the product status to

    Quote Originally Posted by oztraveller06 View Post
    Murphy's Law said that I would find the answer 10 minutes after I posted the question...

    UPDATE products
    INNER JOIN
    books_out_of_print
    ON products.products_model = books_out_of_print.isbn
    SET products.products_status = 0

    Query OK, 398 rows affected (1.45 sec)


    Thanks all - hopefully this may help someone else in the same situation!

    Cheers
    Glad you figured it out, personally at the onset of reading the expectations (~400 products) the concern was how to uniquely identify the 400 products. Was going to suggest just what you did (select search the products then modify the search to an update). So I would say you had done the hardwork, just needed a refresher. :) happy zenning!!!
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. Replies: 9
    Last Post: 12 Jul 2023, 12:26 AM
  2. v138a Need to get all orders in a date range by sql
    By navido in forum General Questions
    Replies: 12
    Last Post: 23 May 2013, 08:11 PM
  3. v150 SQL Update Query for featured products? Help
    By Limitless in forum General Questions
    Replies: 1
    Last Post: 25 Aug 2012, 07:36 PM
  4. Bulk change to order status using SQL query for certain products?
    By neo2810 in forum Managing Customers and Orders
    Replies: 3
    Last Post: 24 Feb 2012, 08:34 PM
  5. Mass update product expected dates via SQL query
    By misaki in forum General Questions
    Replies: 3
    Last Post: 22 May 2010, 01:18 AM

Posting Permissions

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