如何更新SQL中的多个列?

时间:2017-02-28 22:17:13

标签: php mysql sql multiple-columns

您好我正在尝试更新多列,我该怎么办?第一列是shoe1,想要添加另一列但不能

// shoe1
$query = "SELECT shoe_id, shoes_image, 
         shoes FROM " . $DBPrefix . "shoes";

$params[] = array(':shoe_id', floor($time_passed), 'int');
$db->query($query, $params);

$TPL_shoe1_list = '<select name="shoe1">' . "\n";

while ($row = $db->fetch())
{
    $selected = ($row['shoes'] == $shoe1) ? 'selected="true"' : '';
    $TPL_shoe1_list .= "\t" . '<option value="' . $row['shoes'] . '" ' . $selected . '>' . $row['shoes'] .'</option>' . "\n";
}

$TPL_shoe1_list .= '</select>' . "\n";

1 个答案:

答案 0 :(得分:1)

一般来说,sql语法是

UPDATE table-name 
   SET column-name = value, column-name = value, ...
 WHERE condition

示例:

UPDATE Supplier
   SET City = 'Oslo', Phone = '(0)1-953530', Fax = '(0)1-953555'
 WHERE Id = 15