我想使用约束来更新我的数据库
for ($count = 0; $count <= $size; $count++) {
if($dayOfTheWeek[$count] == "Friday" or $dayOfTheWeek[$count] == "Saturday"){
$query = "UPDATE rota SET title='Guest' WHERE date = '$dateMonthYearArr[$count]' AND starttime = '22:00'";
$dayresult = mysql_query($query);}
}
我有多个用户的$starttime
为22:00,但我只希望更新第一个用户详细信息,其余部分保持不变。我该怎么做呢?
答案 0 :(得分:2)
如果您只想更改一条记录,可以将其附加到语句的末尾:
LIMIT 1
例如:
$query = "UPDATE rota SET title='Guest' WHERE date = '$dateMonthYearArr[$count]' AND starttime = '22:00' LIMIT 1";