|
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
[Back to original message]
|