INSERT INTO `food-foreign-id` (`id`, `foreign-id`)
SELECT `food`.`id`, `food`.`foreign-id` FROM `food`
ALTER TABLE `comments`
ADD COLUMN `peoples_id` INT(255) NOT NULL AFTER `comment`,
ADD INDEX `peoples_id_idx` (`peoples_id` ASC);
ALTER TABLE `comments`
ADD CONSTRAINT `comments_peoples`
FOREIGN KEY (`peoples_id_fk`)
REFERENCES `peoples` (`id_people`)
ON DELETE NO ACTION
ON UPDATE NO ACTION;
SELECT `id`
FROM `table`
WHERE CURTIME() BETWEEN `start_time` AND `finish_time`
AND `next_time` < $current_time;
UPDATE `table` SET `next_time` = `next_time` + `interval`*60
WHERE `id` IN ({$task_list});
UPDATE `table` SET `next_time` = `start_time`
WHERE `next_time` > `finish_time`;
$req = $mysqli->prepare(
"SELECT `id` FROM `content` ".
"WHERE ('' = ? OR `lic` = ?) ".
"AND ('' = ? OR `selection` = ?) ".
"AND ('' = ? OR `type` = ?)"
);
$req->bind_param('ssssss', $lic, $lic, $selection, $selection, $type, $type);
UPDATE `table` SET `proc`=`proc`+1 WHERE ...
INSERT INTO `table` (`id`, `proc`)
VALUES ($id1, $proc1), ($id2, $proc2), ...
ON DUPLICATE KEY UPDATE SET `proc` = VALUES(`proc`)
UPDATE `table` SET `proc` = $proc1 WHERE `id` = $id1
UPDATE `table` SET `proc` = $proc2 WHERE `id` = $id2
SELECT `track`, `phone`, `status`,
to_days(IFNULL(`date_finish`, curdate())) - to_days(`date_add`) as `diff`
FROM `track_tabl` WHERE `id_user` = '$id_user'
SELECT `track`, `phone`, `status`,
to_days(IF(`date_finish` = '', curdate(), `date_finish`)) - to_days(`date_add`) as `diff`
FROM `track_tabl` WHERE `id_user` = '$id_user'
<table>
<thead>
<tr><th>Трек-код<th>Телефон<th>Статус<th>Время в пути
<tbody>
<tr><td>R417...<td>+7900...<td>Прибыло<td>11 дней
<tr><td>...<td>...<td>...<td>...
...
</table>