Results 1 to 2 of 2
  1. #1
    Join Date
    May 2003
    Posts
    1

    Red face Unanswered: Simple SQL Query??

    Hi. I'm having some issues with a query that I require. In my mind it should be simple but for the life of me I can not figure out how to go about doing it. The below query, queries a MSSQL database and returns what security group a web account user is in.

    Now I need another query that will return the opposite of this. Web Accounts that are not in a security group (tblWebAccountGroup.Web_Account_Group_Name_ID != var). Sounds simple to me and possible using an SQL query. At present I've done such queries in PHP by writing two queries and doing a data comparison and return what is different between the two queries. As I'm sure you realize this is a major amount of coding to do this manually. How can I do this using SQL? Any help would be greatly appreciated.

    BTW, I'm using IIS v5.0.2195.3649 with PHP v4.2.3 and MSSQL Server 2000 (v8.00.760 Intel X86). If you need any table schemas or other information please let me know.

    $szQry = "SELECT tblWebAccounts.People_ID, viewPeople.First_Name, viewPeople.Last_Name
    FROM tblWebAccounts, viewPeople, tblWebAccountGroup
    WHERE tblWebAccountGroup.Web_Account_Group_Name_ID=$_POS T[nSecurityGroup]
    AND tblWebAccounts.People_ID=viewPeople.People_ID
    AND tblWebAccounts.Web_Account_ID=tblWebAccountGroup.W eb_Account_ID
    ORDER BY viewPeople.First_Name, viewPeople.Last_Name";

  2. #2
    Join Date
    Feb 2003
    Location
    Auckland, NZ
    Posts
    150
    For a particular Group use the following(NOT Keyword):

    WHERE NOT tblWebAccountGroup.Web_Account_Group_Name_ID=$_POS T[nSecurityGroup]

    For mor than on group use the following(NOT IN Keywords):

    WHERE tblWebAccountGroup.Web_Account_Group_Name_ID NOT IN(1,2,3)

    Values(1, 2, 3) above are obviously the ID of the groups not to include
    JJ Kennedy
    Double J IT Solutions
    www.doublejit.co.nz

    VB 6, VB.NET, ASP.NET, MS SQL Server, MySQL, MS Access

Posting Permissions

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