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 |
|
ayamas
Aged Yak Warrior
552 Posts |
Posted - 2007-06-21 : 05:03:40
|
| Hi guys,Yesterday I was interviewed for a job.One question asked was if the column contains value as 'Males' & the query written isselect * from table where gender='Male'Even if the column contains 'Males' the above query should return the output where ever the gender type is 'Males'.Any idea how to achieve it.Thanks In advance. |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-06-21 : 05:11:35
|
| [code]WHERE GENDER LIKE 'Male%'[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
ayamas
Aged Yak Warrior
552 Posts |
Posted - 2007-06-21 : 05:19:11
|
| Thanks for the reply.I also said the same thing to him.But he said the query is just written like this without a like function.select * fom table where gender='Male'Is there seriously some way to achieve it or was he just fooling around.Thanks |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-06-21 : 05:26:57
|
Add another WHERE condition:Where gender='Male' OR gender = 'Males' But frankly, I would like to go for a straight-forward approach.Equality operator is there for exactness, if you want your search to be fuzzy, I would rather go for LIKE rather than looking for another ways to achieve the same thing.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|
|
|