Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 4 of 4

Thread: SQL Query Help

  1. #1
    chazandchaz is offline Member
    Join Date
    Jul 2006
    Posts
    70

    Question SQL Query Help

    I have a nice split in my product database between products with just one variant and ones with multiple variants. I have created two xml packages to display these products. I don't really want to change them one at a time in the admin section.

    I am trying to write a sql query to update all the products that have more than one variant to a specific xml package. Then do the same for the products that have just one.

    I might just be having a mental block but I just can't seem to get it ironed out. Any help would be greatly appreciated.

    Chaz.

  2. #2
    dhs is offline Member
    Join Date
    Feb 2009
    Posts
    35

    Default

    You could use this to select the items:

    select *
    FROM Product
    WHERE ((SELECT COUNT(VariantID) AS Number
    FROM ProductVariant
    WHERE (Product.ProductID = ProductID)) > 1)

  3. #3
    esedirect is offline Senior Member
    Join Date
    Feb 2010
    Location
    Norfolk, UK
    Posts
    343

    Default

    Usual proviso: BACKUP YOUR PRODUCTION DATABASE FIRST, AND TRY THIS ON YOUR DEVELOPMENT DATABASE BEFORE APPLYING TO YOUR PRODUCTION.

    Code:
    -- this will do for your products with only 1 variant
    update product
    set xmlpackage = 'product.simpleproduct.xml.config'
    where productid in (
    select productid from productvariant
    group by productid
    having count(variantid)=1
    )
    
    -- this will do for your products with more than one variant
    update product
    set xmlpackage = 'product.variantsindropdown.xml.config'
    where productid in (
    select productid from productvariant
    group by productid
    having count(variantid)>1
    )
    Change XMLPackage name accordingly.
    http://www.esedirect.co.uk
    --------------------------------------------------------------------------
    Using MS 9.2.0.0 with the following customisations:

    Lightbox/Fancybox enlarged images;
    Auto-suggest searchbox;
    Extra product information shown only to our IP Address (such as supplier info, costs, etc.);
    Failed transactions emailed via trigger;
    Custom app to show basket contents when customer online;
    Orders pushed through to accounting systems.

    All the above without source!

  4. #4
    chazandchaz is offline Member
    Join Date
    Jul 2006
    Posts
    70

    Smile

    Awesomeness! Pure Awesomeness!

    I really appreciate it. I don't know what was up I just couldn't get my head around it. Thanks so much for you help.

    Chaz.