Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
Copy Format Clear
-- phpMyAdmin SQL Dump -- version 4.9.7 -- https://www.phpmyadmin.net/ -- -- Хост: localhost:8889 -- Время создания: Янв 18 2023 г., 15:03 -- Версия сервера: 5.7.32 -- Версия PHP: 8.0.0 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; -- -- База данных: `excel_analytics` -- -- -------------------------------------------------------- -- -- Структура таблицы `comments` -- CREATE TABLE `comments` ( `id` int(11) NOT NULL, `spreadsheet_export_id` int(11) NOT NULL, `text` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Дамп данных таблицы `comments` -- INSERT INTO `comments` (`id`, `spreadsheet_export_id`, `text`) VALUES (1, 253522, 'test comment 5'), (2, 253521, 'test comment 1'); -- -------------------------------------------------------- -- -- Структура таблицы `requests` -- CREATE TABLE `requests` ( `id` int(11) NOT NULL, `export_id` int(11) DEFAULT NULL, `address` text, `district` text, `applicant_name` text, `applicant_phone` text, `problem` text, `executor` text, `note` text, `regulations` text, `received` text, `сomment_when_closing` text, `spreadsheets_id` int(11) NOT NULL, `imported_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Дамп данных таблицы `requests` -- INSERT INTO `requests` (`id`, `export_id`, `address`, `district`, `applicant_name`, `applicant_phone`, `problem`, `executor`, `note`, `regulations`, `received`, `сomment_when_closing`, `spreadsheets_id`, `imported_at`) VALUES (1, 253522, 'Test street 1', 'Test district 4', 'test user 1', '0004987522', 'rgreg', 'executor 7', 'Будинок багатоповерховий.При відсутності світла немає опалення, води. Просять допомогти', 'erhreh', 'erhhhh', 'etnrtjrt', 10, '2022-12-31 19:19:41'), (2, 253521, 'Test street 2', 'Test district 2', 'test user 2', '0004987643', 'wefgwegg', 'executor 6', 'Затоплення квартири. Наслідки не ліквідуються.', 'ergerher', 'gerer', 'rehhrrehe', 10, '2022-12-31 19:19:41'), (3, 253522, 'Test street 2', 'Test district 1', 'test user 3', '0004987534', 'wegfwgwe', 'executor 1', 'ПОВТОРНО Відсутнє опалення у будинку. Ремонтники приїзджають коли немає світла. Нічого не роблять, лаються з мешканцями.', 'rgerger', 'erhthe', 'ehethe', 10, '2023-01-03 19:19:41'), (4, 253521, 'Test street 1', 'Test district 1', 'test user 1', '0004987651', 'vgewweg', 'executor 1', 'Протікає дах. Звертались в ЖЕК по ремонт, відмовили', 'ewgwegwe', 'wgrgerg', '\'', 10, '2023-01-03 19:19:41'); -- -- Индексы сохранённых таблиц -- -- -- Индексы таблицы `comments` -- ALTER TABLE `comments` ADD PRIMARY KEY (`id`); -- -- Индексы таблицы `requests` -- ALTER TABLE `requests` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT для сохранённых таблиц -- SELECT requests.* FROM (SELECT export_id, max(imported_at) AS imported_at FROM requests GROUP BY export_id) as t JOIN requests ON requests.export_id = t.export_id AND requests.imported_at = t.imported_at ORDER BY `requests`.export_id DESC ; SELECT requests.*, comments.text FROM (SELECT export_id, max(imported_at) AS imported_at FROM requests GROUP BY export_id) as t JOIN requests ON requests.export_id = t.export_id AND requests.imported_at = t.imported_at LEFT JOIN comments ON comments.spreadsheet_export_id = t.export_id ORDER BY `requests`.export_id DESC ;

Stuck with a problem? Got Error? Ask AI support!

Copy Clear