redcoder
redcoder

Reputation: 119

MySQL LIKE clause with comma

What is the meaning of comma in the following SQL statement (using MySQL)?

[...] LIKE '%,cat233,%'

Upvotes: 0

Views: 1876

Answers (4)

Wex
Wex

Reputation: 4686

Looks like it would just match the comma as well; so:

Matches:

"My text,cat233,some other stuff"
"My text ,cat233, some other stuff"
"My text,cat233,"
",cat233,"

Doesn't match:

"My text cat233 some other stuff"
"My text cat233, some other stuff"
"My text, cat233, some other stuff"

Upvotes: 1

Mchl
Mchl

Reputation: 62369

It has no special meaning. It just look for string ,cat233, with 0 or more character in front and 0 or more character after it.

Upvotes: 1

checking for cat233 which is in comma separated values.

Upvotes: 2

Chris Card
Chris Card

Reputation: 3266

Aren't the commas just part of the string to be matched? e.g. "fred,bill,cat233,joe,harry" would match.

Upvotes: 3

Related Questions