SELECT
t1.id,
CONCAT('[{',
GROUP_CONCAT(
(SELECT CONCAT('field1: ', t2.field1, ', field2: ' t2.field2) FROM t2 WHERE t2.id = t1.id)
SEPARATOR ' }, { '
), '}]'
FROM t1 GROUP BY t1.id
CREATE PROCEDURE `make_data`()
BEGIN
DECLARE i INT DEFAULT 1;
WHILE i < 500000 DO
<тут INSERT запрос>
SET i = i + 1;
END WHILE;
END
CALL make_data();
UPDATE ps_category SET active = '0' WHERE level = 3 AND id NOT IN (
SELECT DISTINCT(id_category) FROM ps_category_product IN
(SELECT id_product FROM ps_product WHERE active = '1')
)
<?= Html::a('Принять', ['orders/index','value' => ($orders->id)], ['class'=>'btn btn-primary']) ;?>
<?= Html::a('Принять', ['orders/take-order','value' => ($orders->id)], ['class'=>'btn btn-primary']) ;?>
$get = $request->get(value);
$get = $request->get('value');
public function actionTakeOrder($value) {}
SELECT `id`, `date`, `status` FROM `table`
WHERE uid IN (1,2,3,4,5) AND (
(reg=1 AND date_last < NOW() - INTERVAL 1 DAY) OR (reg=2 AND date_last < NOW() - INTERVAL 2 DAY)
OR (reg=3 AND date_last < NOW() - INTERVAL 3 DAY))
SELECT `id`, `date`, `status` FROM `table` WHERE uid IN (1,2,3,4,5) AND date_last < NOW() - INTERVAL reg DAY
CREATE TRIGGER `show_dialog` AFTER INSERT ON `messages` FOR EACH ROW BEGIN
UPDATE users_in_dialogs SET hide = 0 WHERE users_in_dialogs.dialog_id = new.gialog_id AND hide = 1;
END;
SELECT * FROM cities
SELECT *
FROM cities
WHERE region_id IN (1, 2, 3)
SELECT cities.*, regions.* FROM cities
LEFT JOIN regions ON regions.id = cities.region_id