Get the App
SLTechnology News&Howtos  ›  Database  › 

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

Shulou Source: shulou.com Published: 2022-06-01 20:31:38 10月18日 Update

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.

Tags: Characters strings queries questions fields information updates answers specialties available in places actual hours data articles limited knowledge length structure results Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS MariaDB Shulou Technology Docker Shulou Information