MySQL field value stitching, same field loop stitching

Source: Internet
Author: User

SELECT
TRP.REST_ID as merchant ID,
Trp.rest_name as merchant name,
Trp.longitude as longitude,
Trp.latitude as Latitude,
Trp.is_premium as whether the brand,
Trp.is_new as whether new stores,
Ters.overall_score as Store reviews (merchandise),
Ters.service_score as Store evaluation (service attitude),
Tcl.category_name as category (Level I),
(SELECT group_concat (Terl.category_name_level2 ORDER by terl.category_name_level2 asc SEPARATOR ' | ')
From T_e_rest_category_city Terl
where
Terl. ' Month ' = TRP. ' Month ' and Terl.city_code = Trp.city_code and terl.rest_id = trp.rest_id) as category (level two),
(SELECT group_concat (CONCAT (' [', Teot.start_time, '-', Teot.end_time, '] ') ORDER by teot.start_time asc SEPARATOR ' | ')
From T_e_rest_open_time_city Teot
where
Teot. ' Month ' = TRP. ' Month ' and Teot.city_code = Trp.city_code and teot.rest_id = trp.rest_id) as operating length,
Trp.order_month_sales as nearly 30 days single volume,
(SELECT group_concat (tera.description ORDER by tera.description asc SEPARATOR ' | ')
From T_e_rest_active_info Tera
where
Tera. ' Month ' = TRP. ' Month ' and Tera.city_code = Trp.city_code and tera.rest_id = trp.rest_id and Tera.active_type in (' minus ', ' Full ') as full minus,
(SELECT group_concat (tera.description ORDER by tera.description asc SEPARATOR ' | ')
From T_e_rest_active_info Tera
where
Tera. ' Month ' = TRP. ' Month ' and Tera.city_code = Trp.city_code and tera.rest_id = trp.rest_id and Tera.active_type not in ( ' minus ')) as activity

From
T_rest_pandect_info TRP

Left JOIN t_rest_category_mapping TRCP
On
TRCP. ' Month ' = TRP. ' Month '
and
Trcp.city_code = Trp.city_code
and
trcp.rest_id = trp.rest_id
Left JOIN
T_category_level1 Tcl
On
tcl.category_id = Trcp.category
Left JOIN
T_e_rest_score_city ters
On
ters. ' Month ' = TRP. ' Month '
and
Ters.city_code = Trp.city_code
and
ters.rest_id = trp.rest_id
WHERE
TRP. ' Month ' = ' 2018-06 '
and Trp.city_code = 17

LIMIT 100;

MySQL field value stitching, same field loop stitching

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.