r/SQL • • Sep 19 '23

Discussion Is there something wrong with this query.

Post image
158 Upvotes

127 comments sorted by

View all comments

261

u/jlarm Sep 19 '23

You need to change the where condition to be LIKE instead of = and '%chocolate%'

29

u/[deleted] Sep 19 '23

Is there any differences if I put it infront or at the end of the string

164

u/centreewards Sep 19 '23

% works as a wildcard character. In front like '%chocolate' would logically read like 'string ends with chocolate'. 'chocolate%' would be 'starts with'. '%chocolate%' would be equivalent to 'contains'

-2

u/Joe59788 Sep 20 '23

This is correct.