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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

'OR' issue 1

Status
Not open for further replies.

Slippenos

MIS
Apr 22, 2005
333
US
I am trying to write a query ..

Code:
SELECT * FROM TABLE Requests
WHERE 
[red]PrimaryAccountNo LIKE '5'[/red]
[blue]AND Account = 'Bank'
AND AccountMoney > '0'
AND StatusManager LIKE '%';[/blue]

What I want the query to do is pull all records that match this criteria. This SQL is the result of an ASP querystring. If a user knows the Primary Account Number (Primary Key), I want them to input it. When they do- it works fine. When they don't input it- it screws up.

I want them to choose one or the other (red or blue).

What is the work around?



[red]Tools | Internet Options | Clear History[/red]
 
Something like this should work on most platforms.
Code:
SELECT * FROM TABLE Requests
WHERE 
(PrimaryAccountNo LIKE '5')
OR (Account = 'Bank'
AND AccountMoney > '0'
AND StatusManager LIKE '%');

Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)

[noevil]
(Not quite so old any more.)
 
Thank you much.

[red]Tools | Internet Options | Clear History[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top