Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 2.88 KB | None | 0 0
  1. SELECT `company`.`id`              AS `company_id`,
  2.        `company`.`name`            AS `company_name`,
  3.        `brand`.`id`                AS `brand_id`,
  4.        `brand`.`name`              AS `brand_name`,
  5.        `campaign`.`id`             AS `campaign_id`,
  6.        `campaign`.`name`           AS `campaign_name`,
  7.        `campaign_photo`.`id`,
  8.        `campaign_photo`.`direction_id`,
  9.        construction_direction.name AS 'direction',
  10.        `construction_rel_direction`.`price`,
  11.        `campaign_photo`.`name`     AS `photo_name`,
  12.        `construction`.`id`         AS `const_id`,
  13.        Round(construction.LONG, 5) AS 'long',
  14.        Round(construction.lat, 5)  AS 'lat',
  15.        `construction`.`type_id`,
  16.        `construction`.`district_id`,
  17.        `construction`.`address`,
  18.        `construction`.`status`,
  19.        `construction`.`light`,
  20.        `construction`.`size`,
  21.        `address`.`type`            AS `address_type`,
  22.        `address`.`name`            AS `address_name`
  23. FROM   `brand`
  24.        JOIN `company`
  25.          ON `company`.`id` = `brand`.`company_id`
  26.        JOIN `category`
  27.          ON `category`.`id` = `brand`.`category_id`
  28.        JOIN `campaign`
  29.          ON `campaign`.`brand_id` = `brand`.`id`
  30.        JOIN `campaign_photo`
  31.          ON `campaign_photo`.`campaign_id` = `campaign`.`id`
  32.        LEFT JOIN `construction_rel_direction`
  33.               ON `campaign_photo`.`construction_id` =
  34.                            `construction_rel_direction`.`construction_id`
  35.                  AND `campaign_photo`.`direction_id` =
  36.                      `construction_rel_direction`.`direction_id`
  37.        LEFT JOIN `construction_direction`
  38.               ON `campaign_photo`.`direction_id` = `construction_direction`.`id`
  39.        JOIN `construction`
  40.          ON `construction`.`id` = `campaign_photo`.`construction_id`
  41.        JOIN `district`
  42.          ON `construction`.`district_id` = `district`.`id`
  43.        JOIN `construction_address`
  44.          ON `construction_address`.`construction_id` = `construction`.`id`
  45.        JOIN `address`
  46.          ON `address`.`id` = `construction_address`.`address_id`
  47. WHERE  `district`.`is_baku` = 1
  48.        AND `construction`.`is_address_defined` = 1
  49.        AND `brand`.`category_id` IN( '2', '3', '4', '5',
  50.                                      '6', '7', '9', '11',
  51.                                      '15', '16', '17', '18',
  52.                                      '19', '20', '21', '24',
  53.                                      '26', '27', '29', '30',
  54.                                      '32', '33', '34', '35',
  55.                                      '36', '37' )
  56.        AND Month(campaign_photo.date_created) = 10
  57.        AND Year(campaign_photo.date_created) = 2019
  58. GROUP  BY `campaign_photo`.`id`
  59. ORDER  BY `district`.`is_baku` DESC,
  60.           `district`.`name` ASC,
  61.           `construction`.`address` ASC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement