MySQL Forums
Forum List  »  Optimizer & Parser

Re: index cannot be used when passing 'int' to 'varchar'
Posted by: Rick James
Date: June 13, 2012 07:15PM

I have some of the answers...

WHERE int_col = '123abc' -- parses the string literal to get 123
WHERE int_col = 'abc' -- parses the string to get 0
To convert a string to an int, you can do 0+'literal' or 0+char_col
WHERE int_col = '1234' -- seems (in newer versions of MySQL) to be equivalent to
WHERE int_col = 1234

The troubling case you had was none of the above --
WHERE char_col = 1234

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: index cannot be used when passing 'int' to 'varchar'
1307
June 13, 2012 07:15PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.