Wednesday, 21 August 2013

MySQL IF Function not recognizing characters with integers

MySQL IF Function not recognizing characters with integers

The issue I am having is that the IF function in MySQL is not correctly
telling me if an ID is or is not located in the second table. Here is
where you can view what I am doing
http://sqlfiddle.com/#!2/501513/4'
SELECT c.id AS clientID, IF (e.id, 'yes', 'no') AS hasID
FROM Table1 c LEFT JOIN Table2 e ON (c.id = e.id)
WHERE c.id IN ("123456","H100512","94061","OW59556","OR37615");
If you notice that the values "H100512" and "w76789" should both say 'yes'
and not 'no' because they are found in the second table. I notice that if
I take away the letter from the id in the query and in the table then it
will correctly say whether it is there present in the table or not. Am I
doing something wrong in the IF Function?

No comments:

Post a Comment