View Full Version : mysql :: strict string compare
voxecho
11-19-2008, 08:07 PM
is there anyway to get a strict string compare in a select statement?
e.g. select * From tblename where fieldname === 'Some Value';
it would then ignore a row with 'some value' as the field value
-Thanks
oesxyl
11-19-2008, 11:23 PM
is there anyway to get a strict string compare in a select statement?
e.g. select * From tblename where fieldname === 'Some Value';
it would then ignore a row with 'some value' as the field value
-Thanks
select * from tblname where strcmp(fieldname,'Some Value') = 0
regards
voxecho
11-19-2008, 11:58 PM
excellent, thank you
oesxyl
11-20-2008, 12:00 AM
excellent, thank you
you are welcome, :)
best regards
Fumigator
11-20-2008, 12:33 AM
The MySQL manual states that STRCMP is case insensitive, meaning STRCMP('Fumigator', 'fumigator') will return 0. Is this true? I can't test it atm.
oesxyl
11-20-2008, 01:08 AM
The MySQL manual states that STRCMP is case insensitive, meaning STRCMP('Fumigator', 'fumigator') will return 0. Is this true? I can't test it atm.
I don't find any mention about that, so I tested and you are right, is case insensitive.
select strcmp('Fumigator', 'fumigator');
result is 0 same like for:
select strcmp('Fumigator', 'Fumigator');
try this:
select binary 'Fumigator' = 'fumigator';
return 0
select binary 'Fumigator' = 'Fumigator';
return 1
seems that comparison are case insensitive by default that's why we must use binary. :)
best regards
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.