tags:

views:

50

answers:

4

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

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

+3  A: 

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

Chris Card
+2  A: 

checking for cat233 which is in comma separated values.

Srinivas Reddy Thatiparthy
You are right, although using CSV inside a database cell is horrible design, plus it's slow (string searching). For some reason, people insist on implementing it instead of a 1-to-n table.
Piskvor
+1  A: 

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.

Mchl
+1  A: 

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"
Wex