Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of the problem with query string in MySQL integer field

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the detailed explanation of the problems with the query string in the MySQL integer field. I hope I can add and update some knowledge to you. If you have any other questions to know, you can continue to follow my updated article in the industry information.

In MySQL, querying for a string in an integer field returns all zero results, which should be null or empty.

For example, table structure information:

CREATE TABLE `t` (`name` char (20) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `id` int (11) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

Data in the table:

Mysql > select id from tantalizers Musashi + | id | +-+ | 0 | | 0 | 1 | +-+

The query string a returns all zeros:

Mysql > select id from t where id='a';+----+ | id | +-+ | 0 | 0 | +-+

Warning message:

Mysql > show warnings +-+ | Level | Code | Message | +-- -+ | Warning | 1292 | Truncated incorrect DOUBLE value:'a' | +-+

Query string'1a', which can return 1:

Mysql > select id from t where id='1a';+----+ | id | +-- + | 1 | +-+

Alarm message:

Mysql > show warnings +-- + | Level | Code | Message | +- -+ | Warning | 1292 | Truncated incorrect DOUBLE value: '1a' | +-+

Read the above about the MySQL integer field query string problems detailed explanation, hope to bring some help to everyone in the practical application. Due to the limited space in this article, it is inevitable that there will be deficiencies and need to be supplemented. If you need more professional answers, you can contact us on the official website for 24-hour pre-sales and after-sales to help you answer questions at any time.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 292

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report