MySQL WHERE 子句
MySQL WHERE clause
内爆数组后是否可以有一个 WHERE 子句?我只需要插入优先级 >=1 的行。谢谢。
$array = array();
foreach ($priority as $priority)
$array[] = "('$id', '$studentname', '$title', '$academicdiscipline', '$priority')";
$query = "INSERT INTO flux_project_selection (id, studentname, title,
academicdiscipline, priority) VALUES ". implode(',', $array);
Insert 语句不应包含 where
子句。而是使用 PHP 来过滤进入 $array
变量的内容。这是一个例子:
<?php
$array = array();
foreach ($priority as $priority) {
if ($priority >=1) {
$array[] = "('$id', '$studentname', '$title', '$academicdiscipline', '$priority')";
}
}
$query = "INSERT INTO flux_project_selection (id, studentname, title,
academicdiscipline, priority) VALUES ". implode(',', $array);
?>
内爆数组后是否可以有一个 WHERE 子句?我只需要插入优先级 >=1 的行。谢谢。
$array = array();
foreach ($priority as $priority)
$array[] = "('$id', '$studentname', '$title', '$academicdiscipline', '$priority')";
$query = "INSERT INTO flux_project_selection (id, studentname, title,
academicdiscipline, priority) VALUES ". implode(',', $array);
Insert 语句不应包含 where
子句。而是使用 PHP 来过滤进入 $array
变量的内容。这是一个例子:
<?php
$array = array();
foreach ($priority as $priority) {
if ($priority >=1) {
$array[] = "('$id', '$studentname', '$title', '$academicdiscipline', '$priority')";
}
}
$query = "INSERT INTO flux_project_selection (id, studentname, title,
academicdiscipline, priority) VALUES ". implode(',', $array);
?>