insert into select 中报错Truncated incorrect DOUBLE value

mysql中出现 Truncated incorrect DOUBLE value: 'ALLNULL',是由于where条件中的参数值类型和字段类型不一致

1、字段 user_name 是字符串类型,下面我没加双引号,报错

INSERT INTO `qxt_fast_swtich_log`(`user_id`, `username`, `company`, `memo`, `isp_id`, `province`, `create_time`, `record`)

SELECT
    c.user_id userId,
    c.username userName,
    c.company company,
    c.memo memo,
    t.des_gw ispId,
    t.province province
FROM
    table_a t,
    table_b c
WHERE
    t.user_name = c.user_id
    AND t.STATUS = '1'
    AND user_name IN ( 123456, 123457)

2、加上双引号,执行正常

INSERT INTO `qxt_fast_swtich_log`(`user_id`, `username`, `company`, `memo`, `isp_id`, `province`, `create_time`, `record`)

SELECT
    c.user_id userId,
    c.username userName,
    c.company company,
    c.memo memo,
    t.des_gw ispId,
    t.province province
FROM
    table_a t,
    table_b c
WHERE
    t.user_name = c.user_id
    AND t.STATUS = '1'
    AND user_name IN ( '123456', '123457' )

你可能感兴趣的:(java)