Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

QUERYProblem, Need help with WHERE Clause.

Status
Not open for further replies.

jmiller79

Programmer
Jul 13, 2004
48
US
But I have come across a problem where when the user creates a report they want all of there companies users to see the report also. So instead of each user logging in and creating that same report. I have placed a checkbox on the bottom of the save report page that if check will also make available to all users in that company. That works fine. But here is the dilemma, probably real easy but just thinking to hard. I need a SQL statement where it will display the users reports and there companies report, only who is logged in. here is my current SQL
Code:
SELECT * 
FROM SAVEDREPORT
WHERE UsersID = '{UserID}' <-- (Session)
Now I want to add
Code:
SELECT * 
FROM SAVEDREPORT
WHERE UsersID = '{UserID}' AND CompanyID = ‘{CompanyID}’ AND Company = ‘Yes’ <-- Checkbox on save reports page value.
I need this table to display all of the users reports and anyone else who has save reports to the company. I think I have explained well. If not please ask. Thanks
 

You may need to reformat your question,

1. what's the data looks like
2. what's the result you want?

 
SELECT *
FROM SAVEDREPORT
WHERE UsersID = '{UserID}' OR (CompanyID = ‘{CompanyID}’ AND Company = ‘Yes’)

Does this get you what you want?

Questions about posting. See faq183-874
 
SELECT *
FROM SAVEDREPORT
WHERE UsersID = '{UserID}' OR (CompanyID = ‘{CompanyID}’ AND Company = ‘Yes’)

My results from this will be either all UsersID or all Company i need both.I am going to post data in next post.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top