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

Select * where HOW DO I GET TWO VALUES?

Status
Not open for further replies.

plasma800

Technical User
Jun 2, 2005
21
US
Ok, trying to make a sql select statment that will return a record set containg two values for one column.

Like this

Select * from TABLE1 where BRAND='abc' or 'xyz'

I want it to return all of ABC and all of XYZ but not DEF and not GHR

This obviusly doesn't work but I know there is a way, I just can't get the syntax right.

Any ideas??

Thanks!
 
Select * from TABLE1 where BRAND='abc' or [!]BRAND=[/!]'xyz'

or...

Select * from TABLE1 where BRAND in('abc','xyz', 'DEF')


-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Ive tried these and neither seem to work..

Here is my exact statement

objRs.Open "SELECT ProdID, ProdURL, ProdSKU, Category, ThumbImageURL, LinkText, ProdURL, ProdMiniDescription FROM bproducts WHERE Manufacturer='6' and Category='part' or Category = 'processor'"

and the page gives me this error

ADODB.Recordset error '800a0e7d'

The connection cannot be used to perform this operation. It is either closed or invalid in this context.

/phonesystems/panasonic/parts3.asp, line 5

However if I flip back to this statment

objRs.Open "SELECT ProdID, ProdURL, ProdSKU, Category, ThumbImageURL, LinkText, ProdURL, ProdMiniDescription FROM bproducts WHERE Manufacturer='6' and Category='part'" , objCn, 1, 3

Page works great
 
OMG.. i left off the , objCn, 1, 3 Im so sure!!!
 
Anyway it's not safe to mix AND and OR operators without parens.
Use either this:
WHERE Manufacturer='6' AND (Category='part' OR Category='processor')
or this:
WHERE Manufacturer='6' AND Category IN ('part','processor')

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top