开发者

Mysql Fulltext Search on numeric IP

I stored the IP as INT(10) in a mysql table. I display the IP as a address and the user should be able to search for a address rather than a numeric value. I can't see a way to tell MySQL that it has to perform an INET_NTOA for the fulltext search. Is there a w开发者_如何学Pythonay I can easily do that within a query or should I just store the IP as char(), i don't like it since it's about 3 times larger than the numeric value.


You should be able to do something like this -

SELECT INET_NTOA(stored_address) AS match FROM my_table
WHERE LOCATE(query, match) != 0

I wouldn't necessarily recommend it for a large table, though - it'll end up having to convert every single stored IP address in order to get you your results.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜