inert into & update 一次操作多条记录
INERT INTO
SQL:
INSERT INTO `userTable` (`user_id`, `user_name`) VALUES (1, 'dsf'), (2, 'fgy'), (3, 'faad');
PHP:
$a = 1; while (5 == $a) { if (1 == $a) $sql = "INSERT INTO tbl_name (col1,col2) VALUES ($a,$b)"; else $sql .= ",($a,$b)"; $a++; $b++; } mysql_query($sql);
UPDATE
UPDATE categories SET display_order = CASE id WHEN 1 THEN 3 WHEN 2 THEN 4 WHEN 3 THEN 5 END, title = CASE id WHEN 1 THEN 'New Title 1' WHEN 2 THEN 'New Title 2' WHEN 3 THEN 'New Title 3' END WHERE id IN (1,2,3)
抱歉,暂停评论。