Solved

Help creating SQL statment with OR

Posted on 2006-11-21
2
143 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Title # Comments Views Activity
Dreamweaver - Spell check extension 4 494
Dreamweaver Styles 7 405
Wrapping 2 Divs in a Container 8 571
JQuery form validation for bootstrap 1 198
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…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

726 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