Solved

Help creating SQL statment with OR

Posted on 2006-11-21
2
144 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
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 is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

707 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