sql 在查询语句中将整数转为IP字符串实现语句
本文章介绍了关于sql 在查询语句中将整数转为IP字符串实现语句,有需要的同学可以参考一下下本文章
数据表的结构是——
代码如下 | 复制代码 |
CREATE TABLE [dbo].[ac_mainctls_new] ( [id] [int] NULL , [ctlip] [bigint] NULL , [ctlname] [char] (30) COLLATE Chinese_PRC_CI_AS NULL , ) |
其中ctlip是设备的IP地址,以整数方式存储。
虽然可以用程序将整数转为IP字符串,但多了一道工序有点麻烦。于是我想直接在SQL查询语句中将其转为IP字符串。
经过思索与调试,我完成了该查询语句——
代码如下 | 复制代码 |
SELECT CAST(ctlip / 0x1000000 AS varchar(3)) + '.' + CAST(ctlip / 0x10000 % 0x100 AS varchar(3)) + '.' + CAST(ctlip / 0x100 % 0x100 AS varchar(3)) + '.' + CAST(ctlip % 0x100 AS varchar(3)) AS itr, *FROM ac_mainctls_new |
复制代码
查询结果为——
ipstr ctlip
代码如下 | 复制代码 |
192.168.10.32 3232238112 192.168.10.35 3232238115 192.168.10.21 3232238101 192.168.10.19 3232238099 |
验证通过。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

This article explores optimizing MySQL memory usage in Docker. It discusses monitoring techniques (Docker stats, Performance Schema, external tools) and configuration strategies. These include Docker memory limits, swapping, and cgroups, alongside

This article addresses MySQL's "unable to open shared library" error. The issue stems from MySQL's inability to locate necessary shared libraries (.so/.dll files). Solutions involve verifying library installation via the system's package m

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

This article compares installing MySQL on Linux directly versus using Podman containers, with/without phpMyAdmin. It details installation steps for each method, emphasizing Podman's advantages in isolation, portability, and reproducibility, but also

This article provides a comprehensive overview of SQLite, a self-contained, serverless relational database. It details SQLite's advantages (simplicity, portability, ease of use) and disadvantages (concurrency limitations, scalability challenges). C

This guide demonstrates installing and managing multiple MySQL versions on macOS using Homebrew. It emphasizes using Homebrew to isolate installations, preventing conflicts. The article details installation, starting/stopping services, and best pra

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]
