我有以下查询,所有''
都显示为空字符串
INSERT INTO `locations` ( `house`,`house_number`,`road`,`city`,`state`,`country`,`country_code`,`supermarket`,`county`,`place_of_worship`,`city_district`,`suburb`,`neighbourhood`,`pedestrian`,`postcode`)
VALUES ('','','','Gemeinde Wien','Vienna','Austria','at','','W','Saint Stephen\'s cathedral','Innere Stadt','Innere Stadt','Textilviertel','Stephansplatz','1010');
表格结构
所有字段的默认值均为null
。
问题
所以问题是,我怎样才能得到空字符串保持其默认值?
答案 0 :(得分:3)
您可以只使用null
,而不是插入''
INSERT INTO`locations`(`house`,`house_number`,`road`,`city`,`state`,`country`,`country_code`,`supermarket`,`county`,`place_of_worship`,`city_district`,`suburb`,`neighbourhood`,`pedestrian`,`postcode`)
VALUES (null,null,null,'Gemeinde Wien','Vienna','Austria','at','','W','Saint Stephen\'s cathedral','Innere Stadt','Innere Stadt','Textilviertel','Stephansplatz','1010');
或者不要插入像这样的东西
INSERT INTO `locations` (`city`,`state`,`country`,`country_code`,`supermarket`,`county`,`place_of_worship`,`city_district`,`suburb`,`neighbourhood`,`pedestrian`,`postcode`)
VALUES ('Gemeinde Wien','Vienna','Austria','at','','W','Saint Stephen\'s cathedral','Innere Stadt','Innere Stadt','Textilviertel','Stephansplatz','1010');