在之前一篇blog中有提到mysql常用数据库语句时,使用过以下语句:
insert into new_table select NULL,a.phone,name,age,address,NULL, b.birth
from students a, info_table b
where studentnum in (
'20180722121735',
'20180721174759',
'20180720103621',
'20180718122414'
) and a.phone= b.phone
前两天用时还挺好,换了一台mysql服务器后就突然报错,错误信息是“Incorrect integer value: '' for column 'idx' at row 1”,万能的www一搜发现是mysql服务器版本不一样导致,mysql版本到5以上的就会这样,插入空字符要使用NULL,因此正确的语句应该是:
insert into new_table select NULL,a.phone,name,age,address,NULL, b.birth
from students a, info_table b
where studentnum in (
'20180722121735',
'20180721174759',
'20180720103621',
'20180718122414'
) and a.phone= b.phone
仅记之