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 |
|
namitjung
Starting Member
10 Posts |
Posted - 2006-06-26 : 08:44:44
|
| Hi All, I am trying to return the exact matching row from sql in asp.The column type is varchar so i use wild char characters to return the row but it didn't work.I also tried to use IN statement in sql but it also didn't work.I would like to explain the problem scenario as follows:TableName: usersuserid username useremail matchtypes1 Bob bob@mail.com 1,4,5,132 Jessica jes@mail.com 3,21,45,673 Ken ke@mail.com 13,42,124 Stephe ste@mai.com 103,24,2035 Andrew and@mail.com 3,12,45I am creating dating site,so whenever a match is found it should send email to the respective user. In matchtypes column, matchid are inserted as text.i got problem to extract the exact match records.let's say we have to extract those records which should match with 3. For that I used following sql statementselect * from users where matchtypes like '%3%'but sql returns all records since there is 3 in every row. But i want it to extract only two records (Jessica and andrew) since they have exact match .Is thery any sql statement which i can use to extract the exact records.Thanx in advance |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-06-26 : 08:47:30
|
| [code]select * from users where ',' + matchtypes + ',' like '%,3,%'[/code]Peter LarssonHelsingborg, Sweden |
 |
|
|
namitjung
Starting Member
10 Posts |
Posted - 2006-06-26 : 08:51:48
|
| thanx a lot i think it must work..but i didn't get after where "," + matchtypes + "," . Is it column name? |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-06-26 : 08:54:53
|
| No, the ',' puts commas before and after your column MatchTypes, in case that the wanted MatchType is first or last in the csv list.Peter LarssonHelsingborg, Sweden |
 |
|
|
namitjung
Starting Member
10 Posts |
Posted - 2006-06-26 : 08:58:13
|
| Thank you very much....My problem is solved...Thank you again. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|
|