?
Solved

Help creating SQL statment with OR

Posted on 2006-11-21
2
Medium Priority
?
145 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 1000 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 1000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

752 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