Page 1 of 1

MySQL LIKE String Comparisons

Posted: Wed Oct 10, 2007 9:31 am
by kendall
HI

in a MySQL statement I am doing a

Code: Select all

WHERE [column] LIKE '%A'
so that the rows whos "column" data starts with "A" will be returned.

However this is not happening...in fact what is happening is that results are being returned that have "a" and "dam" but not "Adam"

What will cause the statement to act like this?

Kendall

Posted: Wed Oct 10, 2007 9:38 am
by Zoxive
You have it backwards if you want it to get every row that STARTS with A.

Code: Select all

LIKE 'A%'
% Basically Means Anything (Ex `*` Astrix), so you want to match A + anything.

What you have, is returning Everything that Ends in A. And this is case-insensitive.

[SOLVED]

Posted: Wed Oct 10, 2007 9:44 am
by kendall
OOoohhhhh my bad! :oops: