BurningBagel BurningBagel - 13 days ago 5
MySQL Question

SQL Error Code 1366 Incorrect integer value at row 88163

I'm trying to do the following query

INSERT INTO 'table_1'(column_1)
SELECT DISTINCT 'column 2'
FROM other_schema.table2;


Both of those columns have their fields set to INT(255), and yet I get the following error:

"Error Code: 1366. Incorrect integer value: 'column2' for column 'column2' at row 88163"

I even went and checked the individual row, but the field is a number(5800 to be precise).

I did some tinkering, and it seems that if I try to limit the select, it always accuses the row immediately after the upper limit of being of an incorrect value.

Answer

The way you've written your query currently is that you're trying to INSERT a string into your integer column. When you do

SELECT DISTINCT 'column2'

you are selecting the literal string 'column2' and not the values from that column. I would unquote the references to your table and column:

INSERT INTO table SELECT DISTINCT column2 FROM ...