这里的一切都在工作,除了UPDATE命令...... INSERT运行正常但是唉,我被卡住了。
$queryLastDateArray = "SELECT date FROM schedule ORDER BY ID DESC LIMIT 1";
$lastDateArray = mysql_query($queryLastDateArray);
while($row = mysql_fetch_array($lastDateArray))
{
$lastDate = $row['date'];
}
$lastDatePlusOne = date("Y-m-d", strtotime("+1 day", strtotime($lastDate)));
$newDatesArray = GetDays($lastDatePlusOne, $_POST[date]);
$i = 0;
while($i < count($newDatesArray))
{
if ((date('D', strtotime($newDatesArray[$i]))) == 'Fri')
{
$insDate = "INSERT INTO schedule (date) VALUES ('$newDatesArray[$i]')";
$result = mysql_query($insDate);
$insEmp = "UPDATE schedule SET schedule.jakes = schedule_default.jakes FROM schedule, schedule_default WHERE schedule.date = '$newDatesArray[$i]' AND schedule_default.ID = '5'";
$result2 = mysql_query($insEmp);
}
$i++;
}
答案 0 :(得分:2)
尝试编写如下更新:
"UPDATE schedule SET schedule.jakes = (SELECT schedule_default.jakes FROM schedule_default WHERE schedule.date = '$newDatesArray[$i]' AND schedule_default.ID = '5')";
答案 1 :(得分:1)
多表UPDATE
语法为:
UPDATE schedule, schedule_default
SET schedule.jakes = schedule_default.jakes
WHERE schedule.date = '$newDatesArray[$i]'
AND schedule_default.ID = '5'