SELECT *
FROM `db_images` AS `i1`
JOIN `db_images` AS `i2` ON `i1`.`image_hash` = `i2`.`image_hash`
AND `i1`.`image_id` != `i2`.`image_id`
JOIN `db_apartments_images_links` AS `a1` ON `a1`.`image_id` = `i1`.`image_id`
JOIN `db_apartments_images_links` AS `a2` ON `a2`.`image_id` = `i2`.`image_id`
AND `a1`.`apartment_id` = `a2`.`apartment_id`
...
`time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
...
# cd /usr/share/zabbix-server-mysql/
# gunzip < schema.sql.gz | mysql -uroot -p zabbix
# gunzip < images.sql.gz | mysql -uroot -p zabbix
# gunzip < data.sql.gz | mysql -uroot -p zabbix
CREATE TABLE IF NOT EXISTS oF_tour_table_'15' LIKE oF_tour_table_template
SELECT `cat`.`id`, `cat`.`name`
FROM `category` AS `cat`
LEFT JOIN (
SELECT DISTINCT `parent_category_id` AS `parent`
FROM `category`
) AS `sub` ON `cat`.`id` = `sub`.`parent`
WHERE `sub`.`parent` IS NULL
SELECT `t1`.`name`, `t1`.`val`, `t1`.`date`
FROM `table` AS `t1`
JOIN (
SELECT `name`, MAX(`date`) AS `date`
FROM `table`
GROUP BY `name`
) AS `t2` ON `t2`.`name` = `t1`.`name` AND `t2`.`date` = `t1`.`date`
SELECT `p`.`title`, `p`.`text`, `t`.`tag`
FROM (
SELECT `title` FROM `posts` WHERE ... LIMIT 10
) AS `p`
LEFT JOIN `post_tag` AS `pt` ON `pt`.`post_id` = `p`.`id`
LEFT JOIN `tags` AS `t` ON `t`.`id` = `pt`.`tag_id`
ORDER BY `p`.`title`, `t`.`tag`
SELECT `doc`.`id`
FROM `doc`
JOIN (
SELECT `doc_id`
FROM `value_attribute`
WHERE `attribute_id` = :attr1_id AND `value_varchar` LIKE :attr1_val
) AS `a1` ON `a1`.`doc_id` = `doc`.`id`
JOIN (
SELECT `doc_id`
FROM `value_attribute`
WHERE `attribute_id` = :attr2_id AND `value_int` = :attr2_val
) AS `a2` ON `a2`.`doc_id` = `doc`.`id`
...
SELECT DISTINCT `t`.`id`, `i`.`id`
FROM `cats` AS `c`
JOIN `cats` AS `t` ON `t`.`NSLeft` >= `c`.`NSLeft`
AND `t`.`NSRight` <= `c`.`NSRight`
LEFT JOIN `cats_bind` AS `cb` ON `cb`.`cat_id` = `t`.`id`
LEFT JOIN `items` AS `i` ON `i`.`category_id` = `t`.`id`
OR `i`.`id` = `cb`.`item_id`
WHERE `c`.`id` = :root_category
ORDER BY `t`.`title`, `i`.`title`