View Single Post

   
  #1 (permalink)  
Old 06-13-2008, 02:59 PM
jammiepodger
 
Posts: n/a
Default Problem with string comparison

I have been using MySQL on and off for a number of years but I am
stumped by this problem.

I am doing a select which requires a join to a second table using an
account key, I have a WHERE clause which ensures that I only get the
correct type of account.
Basically the type of account is 'CUSTOMER' but if I use the code

....
WHERE ACCOUNT.TYPE="CUSTOMER"
....

Then I get no matches.
However, if I use

....
WHERE STRCMP(ACCOUNT.TYPE,"CUSTOMER")=0
....
or
....
WHERE LEFT(ACCOUNT.TYPE,8)="CUSTOMER"
....

Then I get matches as expected.

I should add that the ACCOUNT.TYPE field has only upper case content
and is 8 characters in length.
Version of MySQL is 5.0.27 running on Fedora Core 5.

Could anyone explain why I cannot get a result set if I just use the
equals operator?


Please note I first posted this to comp.databases - for some reason I
missed this group originally.
Reply With Quote