You are here: Re: OR in the WHERE Clause? « MsSQL Server « IT news, forums, messages
Re: OR in the WHERE Clause?

Posted by Erland Sommarskog on 06/30/06 22:06

Alex (iamalex84@gmail.com) writes:
> I am trying to create a system that will select candidates for a job
> based on certain criteria (i.e. Supperted States)
>
> The candidates are allowed to choose up to 5 supported states. The
> problem comes when creating the query to pull the candidates out.
>
> I can get it to work with only one supported state, no problem. But I
> have no idea how to tell the DB to look through SupportedState1 OR
> SupportedState2 OR SupportedState3 OR SupportedState4 OR
> SupportedState5 to find the particular state that the job is in.
>
> Does an OR operator exist; or at least some mechanism for achieving
> this? Maybe there is a smarter way to implement this instead of 5
> seperate fields for the supported states?

There is an OR operator. But I have no clue how you should write the query
since I don't know your tables.

But if you have five columns for supported states, and you have the
possibility to redesign, do so. Make "supported states" table instead.
Then you may find that there is no reason to have a limit on five states,
at least not from the database point of view.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация