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 |
kennyb
Starting Member
5 Posts |
Posted - 2010-12-16 : 22:43:18
|
I have two columns TodaysOwner and TodaysTrainer:TodaysTrainer------------TodaysOwnerCARROLL JOSIE------------DONVER STABLESIDER ALVIN--------------C & R STABLE LLC & FRANK ADOLPH LLCCULOTTA RAY--------------LORI CULOTTACORMIER DONALD-----------HOPE LAMARCHEVAZQUEZ GAMALIEL---------MICHAEL J GILLCORRADO ROBERT-----------CORRADO ROBERT MARX JOSEPHBINDNER WALTER M JR------MASON C RUDDCRIOLLO MANUEL-----------SILVER DIAMOND THOROUGHBREDS INCTHOMPSON YVETTE----------YVETTE THOMPSONWhen I run a SELECT statement with the WHERE clause TodaysTrainer = TodaysOwner, it only works when the names are exact and in the same order. As you can see, sometimes there are also multiple owners.Can someone please help me construct a where clause that would take the first 5 letters of the string in the TodaysTrainer column and return true if it was like the string in the TodaysOwner column?I think this would be accurate enough for what I want. It would have picked up Culotta, Corrado, and Thompson in the above sample data.Thanks in advanceKB |
|
dataguru1971
Master Smack Fu Yak Hacker
1464 Posts |
Posted - 2010-12-16 : 23:02:52
|
WHERE TodaysOwner like '%' + LEFT(TodaysTrainer,5) + '%' Poor planning on your part does not constitute an emergency on my part. |
 |
|
kennyb
Starting Member
5 Posts |
Posted - 2010-12-16 : 23:40:34
|
Wow DataGuru,I'm amazed and so thankful. It works perfectly for my needs.Your moniker is sooo right on.KB |
 |
|
|
|
|