简体   繁体   中英

Conversion failed when converting the varchar value error

I am keep getting this error after added inner join

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')

Error

Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '127.0.0.1' to data type int.

How can I FIX IT>?

Take a look at this; http://daipratt.co.uk/mysql-store-ip-address/ . . It requires some tweaking to store an IP Address.

您的问题只是将存储在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)

I think you should convert IP address to int in php (or db) and then compare it. There is function ip2long() in PHP

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM