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

Help with a select statement

Status
Not open for further replies.

mtarby

Programmer
Feb 19, 2003
89
US
I'm having a serious brain cramp today - I'm trying to grab records from the database where the Type_ID matches one of three possible values:

"SELECT * FROM EVENTS, TYPES WHERE EVE_TYPE = TYPE_ID AND TYPE_ID=921 OR TYPE_ID=922 OR TYPE_ID=923 ORDER BY TYPE_ID, EVE_START_TIME"

What am I doing wrong? This gives me junk as a result(which is the best way I can describe the records returned!)

Suggestions?

Thanks in advance
 
Use ( )

SELECT * FROM EVENTS, TYPES
WHERE EVE_TYPE = TYPE_ID AND
(TYPE_ID=921 OR TYPE_ID=922 OR TYPE_ID=923)
ORDER BY TYPE_ID, EVE_START_TIME


hth,
Foxbox
ttmug.gif
 
more clearer:

SELECT * FROM EVENTS, TYPES
WHERE (EVE_TYPE = TYPE_ID) AND
(TYPE_ID=921 OR TYPE_ID=922 OR TYPE_ID=923)
ORDER BY TYPE_ID, EVE_START_TIME

VJ
 
SELECT * FROM EVENTS, TYPES
WHERE EVE_TYPE = TYPE_ID AND TYPE_ID IN (921, 922, 923)
ORDER BY TYPE_ID, EVE_START_TIME

Try this.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top