|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 10:29 AM
Points: 5,121,
Visits: 20,359
|
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Friday, December 21, 2012 5:24 AM
Points: 366,
Visits: 436
|
|
Gr8 QotD, Thanks...I got it correct...but it was just a calculated guess...as other options were incorrect... look fwd to use this wildcard...
|
|
|
|
|
SSChasing Mays
      
Group: General Forum Members
Last Login: Friday, January 11, 2013 12:41 PM
Points: 621,
Visits: 297
|
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 6:03 PM
Points: 1,055,
Visits: 1,387
|
|
To be strict, the source data was a red herring. A where clause shouldn't be based on the data you have, but the data you want.
In this case, for example, it doesn't matter that "Jim" exists in the source data (or "Tim" or "Kim" or "Bim" for that matter). What matters is that you want to retrieve only rows with "Tim" or "Kim".
If you used "Like '%im'", and "Jim" wasn't in the source data, your query would work. Once. But it would break as soon as someone added any other name like '%im'. If you get in the habit of using shortcuts rather than framing your query properly, you'll be rewriting queries more and more often.
Trust me, I know.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Tuesday, June 04, 2013 6:13 AM
Points: 196,
Visits: 467
|
|
Its good to learn something like this :)
Thanks
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Yesterday @ 5:53 PM
Points: 7,179,
Visits: 7,276
|
|
sknox (2/1/2010) To be strict, the source data was a red herring. A where clause shouldn't be based on the data you have, but the data you want.
In this case, for example, it doesn't matter that "Jim" exists in the source data (or "Tim" or "Kim" or "Bim" for that matter). What matters is that you want to retrieve only rows with "Tim" or "Kim".
If you used "Like '%im'", and "Jim" wasn't in the source data, your query would work. Once. But it would break as soon as someone added any other name like '%im'. If you get in the habit of using shortcuts rather than framing your query properly, you'll be rewriting queries more and more often.
Trust me, I know. Yes, I agree. Now if one of the answers offered had been [^J]im I wonder if anyone would haven fallen into the trap of giving an answer that would work with the given data but not in general - then the source data would have been a real red herring! It was a good question and answer, anyway.
Tom Is minic a gheibheann béal oscailte dorn dúnta. Is minig a cheapas beul fosgailte dòrn dùinte.
http://es.linkedin.com/in/tomthomsonsoftware
|
|
|
|
|
Mr or Mrs. 500
      
Group: General Forum Members
Last Login: Friday, March 15, 2013 10:35 AM
Points: 594,
Visits: 654
|
|
Thanks for asking one I know without having to think about :)
Peter Trast Microsoft Certified ...(insert many literal strings here) Microsoft Design Architect with Alexander Open Systems
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 1:34 AM
Points: 10,990,
Visits: 10,573
|
|
|
|
|