开发者

mysql comparing force BINARY

I have two tables. In one I have column like开发者_运维知识库 INT and in other I have row like VARCHAR where I wait user id or unique id for quest with letters...I want compare if INT = VARCHAR in mysql query. I am using:

BINARY int_row = BINARY varchar_row

is this ok ?


As long as you're comparing only numbers, it won't matter. There will be an implicit conversion anyway so that the varchar and int fields can be compared.

The only problem I can think of is if the varchar field can contain values like this:

1ABCDEFGHIJK

you may get into trouble here, because a conversion of this varchar into a number would result in 1!

To make sure, I would tend to use

BINARY CAST(int_row AS CHAR) = BINARY varchar_row

but this can be overly paranoid - correct me if I'm wrong.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜