Find MySQL string identified by number in warning message

The output of MySQL "show warnings" identifies the problematic lines by number. What is the best way to quickly see all the data for such a row?

For example, after the operator starts, the updateresult indicates "1 warning", and the start show warningsgives the following message: "Data is truncated for the person column on line 65278." How can I select this particular line?

Here is a concrete example of researching a solution limit:

create table test1 (
  id     mediumint,
  value  varchar(2)
);
insert into test1 (id, value) values
  (11, "a"),
  (12, "b"),
  (13, "c"),
  (14, "d"),
  (15, "ee"),
  (16, "ff");
update test1 set value = concat(value, "X") where id % 2 = 1;
show warnings;

This leads to the output of this warning:

+---------+------+--------------------------------------------+
| Level   | Code | Message                                    |
+---------+------+--------------------------------------------+
| Warning | 1265 | Data truncated for column 'value' at row 5 | 
+---------+------+--------------------------------------------+

To get only this line 5, I can do this:

select * from test1 limit 4,1;

which leads to the following:

+------+-------+
| id   | value |
+------+-------+
|   15 | ee    | 
+------+-------+

, limit (4) , , , , , where.

+3
3

, - SELECT , UPDATE:

mysql> UPDATE foo SET bar = "bar" WHERE baz = "baz";
mysql> SHOW WARNINGS;
...
Message: Data truncated for column 'X' at row 420
...
mysql> SELECT * FROM foo WHERE baz = "baz" LIMIT 420,1;

, , , .

+1

LIMIT x, y y x . , , , , ORDER BY , .

, , , , , , , .

0

, , .

, , , , . , , .

, testfield, :

INSERT INTO newtable (
  id,
  field1,
  field2,
  testfield
)
SELECT
  id,
  field1,
  field2,
  testfield
FROM oldtable;

:

SELECT newtable.testfield, oldtable.testfield
FROM newtable
INNER JOIN oldtable ON newtable.id = oldtable.id
WHERE newtable.testfield != oldtable.testfield;

, .

0

Source: https://habr.com/ru/post/1704668/


All Articles