Sherman Lilly
Sherman Lilly

Reputation: 11

1292 Truncated incorrect INTEGER value

What am I not seeing? I have no idea why I am getting this error. It shouldn't even be asking for an integer.

MariaDB [ams]> describe server_current_status;
+----------+-------------+------+-----+---------+----------------+
| Field    | Type        | Null | Key | Default | Extra          |
+----------+-------------+------+-----+---------+----------------+
| id       | int(11)     | NO   | PRI | NULL    | auto_increment |
| serverid | varchar(20) | YES  |     | NULL    |                |
| status   | varchar(20) | YES  |     | NULL    |                |
| notify   | varchar(15) | YES  |     | NULL    |                |
| totime   | varchar(20) | YES  |     | NULL    |                |
| fromtime | varchar(20) | YES  |     | NULL    |                |
+----------+-------------+------+-----+---------+----------------+
6 rows in set (0.00 sec)

MariaDB [ams]> UPDATE server_current_status SET notify = 'SOME' AND status = 'DOWN' WHERE serverid = '8';
Query OK, 0 rows affected, 2 warnings (0.04 sec)
Rows matched: 1  Changed: 0  Warnings: 2

MariaDB [ams]> show warnings;
+---------+------+-------------------------------------------+
| Level   | Code | Message                                   |
+---------+------+-------------------------------------------+
| Warning | 1292 | Truncated incorrect INTEGER value: 'SOME' |
| Warning | 1292 | Truncated incorrect DOUBLE value: 'SOME'  |
+---------+------+-------------------------------------------+
2 rows in set (0.00 sec)

Upvotes: 1

Views: 7687

Answers (1)

Paul Spiegel
Paul Spiegel

Reputation: 31772

notify = 'SOME' AND status = 'DOWN'

This is a boolean expression. The engine reads it as something like

notify = ('SOME' AND (status = 'DOWN'))

So the engine tries to convert 'SOME' to a boolean (which is 0 or 1 in MySQL/MariaDB)

You probably want this:

notify = 'SOME', status = 'DOWN'

Upvotes: 3

Related Questions