Mysql 对数字 IP 进行全文搜索
我将 IP 作为 INT(10) 存储在 mysql 表中。我将 IP 显示为地址,用户应该能够搜索地址而不是数值。我看不出有什么方法可以告诉 MySQL 它必须执行 INET_NTOA 来进行全文搜索。有没有一种方法可以在查询中轻松做到这一点,或者我应该将 IP 存储为 char(),我不喜欢它,因为它大约比数值大 3 倍。
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 way 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够执行类似的操作 -
不过,我不一定会推荐它用于大型表 - 它最终必须转换每个存储的 IP 地址才能获得结果。
You should be able to do something like this -
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.