Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
shawnmolloy
Yak Posting Veteran
93 Posts |
Posted - 2008-05-24 : 01:21:05
|
| Hello,I have a web form with a check box list with 5 values. Each of them is an int value, and the user can select multiple values from the check box list. For example:Status:1) Single2) Married3) In Relationship4) Divorced5) AnyThese values correspond to a column called "RelationshipStatus" which holds an int value of NULL or 0-5.So the value passed to my SQL query would be any combination of 1, 2, 3, 4, or 5 (Which denote any of the above). It could look like this:@Status = '132'Now my question is how would I do a select statement that finds any row with one of those value (Any row with 1, or 3, or 2)? If there is a '5' in the varible then the select statement should return any row regardless of the value.Table Name: "USER_TABLE"Column Name: "Relationship_Status"Value Type: INTThank you experts! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-24 : 01:31:37
|
I think this will work:-SELECT *FROM USER_TABLEWHERE CHARINDEX(CAST(RelationshipStatus AS char(1)),@Status)>0OR CHARINDEX('5',@Status) >0 |
 |
|
|
|
|
|