转换varchar值错误时转换失败

时间:2013-12-12 08:33:04

标签: php sql sql-server database

添加内连接后,我一直收到此错误

SELECT 
   character.dbo.user_character.character_name,
   character.dbo.user_character.wLevel,
   character.dbo.user_character.byPCClass,
   character.dbo.user_character.wMapIndex,
   character.dbo.user_character.wPosX,
   character.dbo.user_character.wPosY,
   ban_info.dbo.account_login.ip
FROM
   character.dbo.user_character
INNER JOIN ban_info.dbo.account_login ON (character.dbo.user_character.wPosY=ban_info.dbo.account_login.ip)
WHERE (character.dbo.user_character.user_no='12100601280065')

错误

Msg 245,Level 16,State 1,Line 1 将varchar值'127.0.0.1'转换为数据类型int。

时转换失败

我如何修改它>?

3 个答案:

答案 0 :(得分:0)

看看这个; http://daipratt.co.uk/mysql-store-ip-address/。 。它需要一些调整来存储IP地址。

答案 1 :(得分:0)

您的问题只是将ban_info.dbo.account_login.ip上存储的Ip地址(不是整数)与存储在character.dbo.user_character.wPosY的整数值进行比较:

INNER JOIN ban_info.dbo.account_login ON (character.dbo.user_character.wPosY = ban_info.dbo.account_login.ip)

答案 2 :(得分:0)

我认为你应该在php(或db)中将IP地址转换为int,然后进行比较。 PHP中有函数ip2long()