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=$_POST[nSecurityGroup]
AND tblWebAccounts.People_ID=viewPeople.People_ID
AND tblWebAccounts.Web_Account_ID=tblWebAccountGroup.Web_Account_ID
ORDER BY viewPeople.First_Name, viewPeople.Last_Name";
Simple SQL Query??
Moderator: General Moderators
-
The Warden
- Forum Newbie
- Posts: 1
- Joined: Mon May 12, 2003 9:55 am
- Location: Canada
I'm not quite sure about your table-structure but as simple example without the where clause you might tryand see wether it helps you.
(tblWebAccountGroup.Web_Account_Group_Name_ID=$_POST[nSecurityGroup]) will be a field in the resultset containing 1 if the condition is true, 0 otherwise for each record.
Code: Select all
$szQry = "SELECT tblWebAccounts.People_ID, viewPeople.First_Name, viewPeople.Last_Name, (tblWebAccountGroup.Web_Account_Group_Name_ID=$_POST[nSecurityGroup])
FROM tblWebAccounts, viewPeople, tblWebAccountGroup";(tblWebAccountGroup.Web_Account_Group_Name_ID=$_POST[nSecurityGroup]) will be a field in the resultset containing 1 if the condition is true, 0 otherwise for each record.