Solved

Help creating SQL statment with OR

Posted on 2006-11-21
2
142 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

856 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