Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT `company`.`id` AS `company_id`,
- `company`.`name` AS `company_name`,
- `brand`.`id` AS `brand_id`,
- `brand`.`name` AS `brand_name`,
- `campaign`.`id` AS `campaign_id`,
- `campaign`.`name` AS `campaign_name`,
- `campaign_photo`.`id`,
- `campaign_photo`.`direction_id`,
- construction_direction.name AS 'direction',
- `construction_rel_direction`.`price`,
- `campaign_photo`.`name` AS `photo_name`,
- `construction`.`id` AS `const_id`,
- Round(construction.LONG, 5) AS 'long',
- Round(construction.lat, 5) AS 'lat',
- `construction`.`type_id`,
- `construction`.`district_id`,
- `construction`.`address`,
- `construction`.`status`,
- `construction`.`light`,
- `construction`.`size`,
- `address`.`type` AS `address_type`,
- `address`.`name` AS `address_name`
- FROM `brand`
- JOIN `company`
- ON `company`.`id` = `brand`.`company_id`
- JOIN `category`
- ON `category`.`id` = `brand`.`category_id`
- JOIN `campaign`
- ON `campaign`.`brand_id` = `brand`.`id`
- JOIN `campaign_photo`
- ON `campaign_photo`.`campaign_id` = `campaign`.`id`
- LEFT JOIN `construction_rel_direction`
- ON `campaign_photo`.`construction_id` =
- `construction_rel_direction`.`construction_id`
- AND `campaign_photo`.`direction_id` =
- `construction_rel_direction`.`direction_id`
- LEFT JOIN `construction_direction`
- ON `campaign_photo`.`direction_id` = `construction_direction`.`id`
- JOIN `construction`
- ON `construction`.`id` = `campaign_photo`.`construction_id`
- JOIN `district`
- ON `construction`.`district_id` = `district`.`id`
- JOIN `construction_address`
- ON `construction_address`.`construction_id` = `construction`.`id`
- JOIN `address`
- ON `address`.`id` = `construction_address`.`address_id`
- WHERE `district`.`is_baku` = 1
- AND `construction`.`is_address_defined` = 1
- AND `brand`.`category_id` IN( '2', '3', '4', '5',
- '6', '7', '9', '11',
- '15', '16', '17', '18',
- '19', '20', '21', '24',
- '26', '27', '29', '30',
- '32', '33', '34', '35',
- '36', '37' )
- AND Month(campaign_photo.date_created) = 10
- AND Year(campaign_photo.date_created) = 2019
- GROUP BY `campaign_photo`.`id`
- ORDER BY `district`.`is_baku` DESC,
- `district`.`name` ASC,
- `construction`.`address` ASC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement