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