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

Select Statement for an SQL

Status
Not open for further replies.

Charlix

Programmer
Nov 19, 2002
85
US
I am having trouble writing a select statement for an sql. I want to select all items for using three variables that can each have values of 0,1,2,3. I want items that are "0" to always be included. This is my select statement:

"SELECT * FROM [Table1] WHERE [Variable1] = 0 OR [Variable1] = 1 AND WHERE [Variable2] = 3 AND [Variable3] = 2"

The select statement doesn't seem to recognize the input for [Variable3] or [Variable2].

What's wrong?
 
Try this:

"SELECT * FROM [Table1] WHERE ( ([Variable1] = 0) AND ([Variable1] = 1 OR [Variable2] = 3 OR [Variable3] = 2) )"

-VJ
 
Can you show some of your data and kind of result you want...

-VJ
 
Sorry everyone,

The select statement gives the correct answer. I just looked at it the wrong way.

Thanks

Charlix
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top