October 27, 2015 at 9:03 pm
Comments posted to this topic are about the item More wildcard searches
October 27, 2015 at 9:09 pm
CREATE TABLE MyTextTable
(
myid INT
, mytext varchar(MAX)
);
GO
INSERT dbo.MyTextTable
( myid, mytext )
VALUES
( 1, 'A good coffee bean is important for brewing a good cup of coffee.' )
, ( 2, 'Coffee fuels the development process.' )
, ( 3, 'Coffee is beloved by everyone.' )
, ( 4, 'Most coffee brewers do not get hot enough.' )
, ( 5, 'People in the US tend to prefer coffee over tea' )
;
GO
If I run this, how many rows are returned?
SELECT
myid
FROM
dbo.MyTextTable AS mtt
WHERE
mytext LIKE '%coffee %';
>Sorry - you were wrong
>Correct answer:
>4
>Explanation:
>All of the rows are returned, as all have "coffee" as a word with a space after the word in the text.
>Ref: LIKE - https://msdn.microsoft.com/en-us/library/ms179859.aspx
>Wildcard Searches - http://www.sqlservercentral.com/articles/T-SQL/130558/
Why is the answer 4!???
October 27, 2015 at 9:43 pm
How can the "correct Answer" be 4 when all rows are returned. By my reckoning there are 5 rows !
October 27, 2015 at 11:05 pm
Sorry can't see it; all the rows are returned is the correct answer. 5 rows were inserted with the word "coffee " (with a space), therefore 5 rows should be returned.
The only exception to this would be if the database in question were Case Sensitive, in which case I would expect the answer to be 3! But since this was not specified I think the general assumption is that the database is Case Insensitive.
To get 4 there must be a missing delete command, or the inserted text was typed in incorrectly.
Hold on..............
Looking again at the inserted values, did you miss the fact that the first line has the word coffee in twice, one of which is followed by a full stop, while the other is followed by a space, in which case it would still be counted?
...
October 27, 2015 at 11:31 pm
Hahaha, reading this and see the ad
"prove your skills on SQLServerCentral".
Funnay.
October 28, 2015 at 12:22 am
looks like the QotD is wrong!
October 28, 2015 at 12:41 am
Wrong Answer Posted for this question. It is 5.
October 28, 2015 at 12:51 am
the correct answer should be 5 🙂
October 28, 2015 at 12:55 am
correct answer for this question should be 5
October 28, 2015 at 1:47 am
Expected 5 😎
You didn't accept 5 :w00t:
Regards
VG
October 28, 2015 at 1:54 am
Correct answer:
4
Explanation:
All of the rows are returned, as all have "coffee" as a word with a space after the word in the text.
WHAT ???
October 28, 2015 at 1:55 am
Yes you're correct should 5 as all 5 contain coffe
October 28, 2015 at 2:16 am
My first thought when I got the wrong answer was 'Obviously need more coffee...' 😛
October 28, 2015 at 2:24 am
Going back to school to learn to count again, thought I had it sussed
October 28, 2015 at 2:28 am
The author possibly overlooked that in the first sentence the word "coffee" is twice.
Viewing 15 posts - 1 through 15 (of 85 total)
You must be logged in to reply to this topic. Login to reply