The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

Odd Query help

Last post 08-27-2008, 6:10 PM by Mike.Griffin. 1 replies.
Sort Posts: Previous Next
  •  08-27-2008, 5:26 PM 10984

    Odd Query help

      IN addition to the previous post, this is the sql query im trying to get fomr using the selected items from a dataviewGrid to get the array of partID to us to restrict the query to only vendors that don;t have an existing many to many relation to the part. seems simple in SQL
      the 1,8,12,15 is the partID collected from the selected Item of a dataviewGrid as a collection of Parts (partsCollection)
    Code:
    SELECT * FROM Vendor
    WHERE VendorID NOT IN(select VendorID from partvendor
    Where PartID IN (1,8,12,15)
    )
    
    

    Richard Young
  •  08-27-2008, 6:10 PM 10987 in reply to 10984

    Re: Odd Query help

    Okay, I just used a single type of query but you'll get the idea, look at this code:

     

    Code:
    EmployeesQuery sub = new EmployeesQuery();
    sub.Select(sub.EmployeeID);
    sub.Where(sub.EmployeeID.In(1, 8, 12, 15));

    EmployeesQuery main = new EmployeesQuery();
    main.Where(main.EmployeeID.NotIn(sub));

    EmployeesCollection coll = new EmployeesCollection();
    coll.Load(main);
    This generates this SQL
    Code:
    SELECT * FROM [Employees] 
    WHERE [EmployeeID] NOT IN
    (
    SELECT [EmployeeID] AS 'EmployeeID' FROM [Employees]
    WHERE [EmployeeID] IN (1,8,12,15)
    )
     

    This POST is awesome and shows how you can write subqueries in some very cool and highly readable ways

     


    EntitySpaces | Twitter | BLOG | Please honor our Software License
View as RSS news feed in XML