The MySQL "show warnings" output identifies problematic rows by number. What's the best way to quickly see all the data for such a row?
For example, after running an update
statement the result indicates "1 warning" and running show warnings
gives a message like this: "Data truncated for column 'person' at row 65278". How can I select exactly that row?
Here is a concrete example exploring the limit
solution:
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;
That results in this warning output:
+---------+------+--------------------------------------------+
| Level | Code | Message |
+---------+------+--------------------------------------------+
| Warning | 1265 | Data truncated for column 'value' at row 5 |
+---------+------+--------------------------------------------+
To get just that row 5 I can do this:
select * from test1 limit 4,1;
resulting in this:
+------+-------+
| id | value |
+------+-------+
| 15 | ee |
+------+-------+
So it seems that the limit
offset (4) must be one less than the row number, and the row number given in the warning is for the source table of the update without regard to the where
clause.