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 |
|
kamal.A
Yak Posting Veteran
70 Posts |
Posted - 2008-07-30 : 13:55:02
|
| HiI need the solution for the below.In my database table I have one field AbleToCover. This field contain multiple values for comma separated. I will select a some fields from that table based on AbleToCover.Example.Table name: Test, Fields: Type, AbleToCoverExample recordsType AbleToCoverTypeEx1 PlumbingTypeEx2 Plumbing,GardeningTypeEx3 Plumbing,Gardening,ElectricsTypeEx4 PlumbingMy requirement is select a Type from Test table where AbleToCover is Plumbing.Result is TypeEx1 TypeEx2 TypeEx3 TypeEx4Because of Plumbing is in all the types.Please help me.Kamal |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-30 : 13:59:15
|
| [code]SELECT TypeFROM TestWHERE ','+AbleToCover + ',' LIKE '%,Plumbing,%'[/code] |
 |
|
|
rohitkumar
Constraint Violating Yak Guru
472 Posts |
Posted - 2008-07-30 : 14:01:03
|
| select * from table where field LIKE '%Plumbing%' |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-30 : 14:15:40
|
quote: Originally posted by rohitkumar select * from table where field LIKE '%Plumbing%'
it wont work correctly in all casesconsider the case where you've similar word like TypeEx5 Plumbing & Gardening,Carpentrythen this will also be returned when you use above query. Thats why i wrapped it within ',' to make sure we take only the same words appearing among the values |
 |
|
|
kamal.A
Yak Posting Veteran
70 Posts |
Posted - 2008-07-30 : 14:46:26
|
| Thanks for your valuable help. Now it is enough for my requirement. Because of I will stored the AbleToCover field in comma seperated only.kamal,. |
 |
|
|
|
|
|