Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select trims spaces from strings - is this a bug or in the spec?

Tags:

mysql

in mysql:

select 'a' = 'a     ';

return 1

like image 896
ripper234 Avatar asked Dec 22 '09 16:12

ripper234


1 Answers

You're not the first to find this frustrating. In this case, use LIKE for literal string comparison:

SELECT 'a' LIKE 'a    ';    //returns 0
like image 164
Sampson Avatar answered Sep 28 '22 14:09

Sampson