Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- EXPLAIN
- select *
- from (
- select b.city_id AS city_id,
- b.type_id AS id,
- bt.strname AS name,
- b.main_id AS id1,
- MAX(CASE WHEN bp.name = 'location' THEN `value` END) AS name1,
- MAX(CASE WHEN bp.name = 'side' THEN `value` END) AS id2,
- CONCAT('сторона ', MAX(CASE WHEN bp.name = 'side' THEN `value` END)) AS name2,
- IF(MAX(CASE WHEN bp.name = 'price' THEN `value` END) = 'н/д', NULL,
- MAX(CASE WHEN bp.name = 'price' THEN `value` END)) AS price,
- 1 AS currency,
- 'rpm' AS price_unit,
- 14 AS dayrazm
- from outdoor.build AS b
- INNER JOIN (select `name`, `value`, build_id
- FROM outdoor.build_property
- where name IN ('location', 'side', 'price')
- AND value IS NOT NULL
- AND value <> '') AS bp ON bp.build_id = b.id
- INNER JOIN outdoor.build_types AS bt ON bt.alias_id = b.type_id
- WHERE b.alive = 1
- AND main_id > 0
- AND city_id
- GROUP BY b.id) AS od
- where city_id = 25
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement