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 7 of 7

Thread: Query Help

  1. #1
    ram is offline Senior Member
    Join Date
    Oct 2007
    Posts
    153

    Default Query Help

    If you run the first query, you will get the result as '65195' If you run the second query, you will get the same result. What I need to do is, if 65195 exists in both the tables (productblocking and productallowlist), the query should return no result. If it just exists in productblocking table, it should return the result. How to do this?

    SELECT p.productid
    FROM product p
    JOIN productblocking pb ON p.productid=pb.productid
    WHERE customerlevelid='5' and p.productid = '65195'

    SELECT p.productid
    FROM product p
    JOIN productallowlist pa ON p.productid=pa.productid
    WHERE customerlevelid='5' and p.productid = '65195' and customerid='62030'

  2. #2
    Jao is offline Senior Member
    Join Date
    Oct 2008
    Posts
    1,132

    Default

    You could use the NOT IN keyword.

  3. #3
    ram is offline Senior Member
    Join Date
    Oct 2007
    Posts
    153

    Default

    I tried but didn't work.

  4. #4
    BFG 9000 is offline Senior Member
    Join Date
    Oct 2006
    Location
    South UK
    Posts
    882

    Default

    Try this :-


    SELECT productid FROM productallowlist where productid NOT IN (select productid from product where customerlevelid='5' and p.productid = '65195' and customerid='62030');


    TTFN

    BFG

  5. #5
    ram is offline Senior Member
    Join Date
    Oct 2007
    Posts
    153

    Default

    No, it didn't work.

    I need help here. There is a query statement in one of the .cs pages.

    ds = db.GetData("select ImageForDisplay from productblocking where productid=" + ProductID + " and customerlevelid=" + CustomerLevelID);

    I need to change this query to

    select ImageForDisplay from productblocking
    where productid=" + ProductID + " and customerlevelid=" + CustomerLevelID
    UNION
    select ImageForDisplay from categoryblock
    where categoryid=" + CategoryID + " and customerlevelid=" + CustomerLevelID

    how can I do this? When I try to change, I get an error.

  6. #6
    ram is offline Senior Member
    Join Date
    Oct 2007
    Posts
    153

    Default

    How can I call the data from a column in a table to a .cs file? Here is what I tried but it compiles without any errors but when I set breakpoints, categoryDiscount is not getting the data. How can i fix this?


    int categoryDiscount = 0;
    DataRow[] drCatDiscount = dsProducts.Tables[1].Select("productid=" + pdId);
    if (drCatDiscount.Length > 0)
    categoryDiscount = DB.RowFieldInt(drCatDiscount[0], "discountpercent");

  7. #7
    Dusty is offline Member
    Join Date
    Jun 2009
    Posts
    176

    Default

    If such isn't getting any data I'd recommend trying to definitively determine if the data for which you're looking contains that data you expect. If there are no rows resulting from your .Select such might explain the behavior you're seeing.

    Dusty
    ASPDotNetStorefront Staff