Solved

Help creating SQL statment with OR

Posted on 2006-11-21
2
139 Views
Last Modified: 2010-04-25
I'm trying to create an SQL which returns any records where 'category' ir equal to any of these four terms: 'Club' 'Club and Bar' 'Restaurant and Club'  'Restaurant, Bar and Club'

My current SQL returns all the records in the database, no matter what is in the 'category' column can someone show me what I'm doing wrong?

rsclubs.Source = "SELECT *  FROM entertainment  WHERE category = 'Club and Bar' OR 'Club' OR 'Restaurant and Club' OR 'Restaurant, Bar and Club'  ORDER BY ID DESC"
0
Comment
Question by:elliottbenzle
2 Comments
 
LVL 11

Accepted Solution

by:
dodge20 earned 250 total points
ID: 17987615
Your don't have the correct OR syntax. I would use the In function.

I would write it like this

rsclubs.Source = "SELECT *  FROM entertainment  WHERE category in ('Club and Bar', 'Restaurant and Club','Restaurant, Bar and Club') ORDER BY ID DESC"

0
 
LVL 70

Assisted Solution

by:Jason C. Levine
Jason C. Levine earned 250 total points
ID: 17989854
Or you can use:

rsclubs.Source = "SELECT *  FROM entertainment  WHERE category = 'Club and Bar' OR category = 'Club' OR category = 'Restaurant and Club' OR category = 'Restaurant, Bar and Club'  ORDER BY ID DESC"

Either the above or dodge20's method is syntatically (is that a word?) correct.  Dodge20's is cleaner...
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now