我想在一行中插入一个值。此行有多个值。当我尝试插入时显示错误 row-1 没有默认值。
$NoName = "Record_name";
$no = "20"; // I want to INSERT this no in row
$sql4 = "INSERT INTO record (date, month, year, $NoName) VALUES ('12-12-2016','12','2017', '$no')";
$result4 = mysqli_query($mysqli,$sql4) or die(mysqli_error($mysqli));
还有一些其他行,例如 no 1、no 2、no 3 我只想在新行中插入 no 1 值,其他值将为空。
最佳答案
您可以向该列添加默认值:
ALTER TABLE record ADD DEFAULT '0000-00-00' FOR date
本文来自:
How to set a default value for an existing column
请注意,您应该使用有效的默认值。
关于php - 在多值行中插入一个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41484192/