我是靠谱客的博主 眼睛大方盒,最近开发中收集的这篇文章主要介绍mysql 同一列拼接_mysql 字段值拼接,同一字段循环拼接,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

SELECT

trp.rest_id as 商户id,

trp.rest_name as 商户名称,

trp.longitude as 经度,

trp.latitude as 纬度,

trp.is_premium as 是否品牌,

trp.is_new as 是否新店,

ters.overall_score as 店铺评价(商品),

ters.service_score as 店铺评价(服务态度),

tcl.category_name as 所属品类(一级),

(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 所属品类(二级),

(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 营业时长,

trp.order_month_sales as 近30天单量,

(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 (‘减‘,‘满‘)) as 满减,

(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 (‘减‘)) as 活动

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;

原文:https://www.cnblogs.com/coriander/p/9335042.html

最后

以上就是眼睛大方盒为你收集整理的mysql 同一列拼接_mysql 字段值拼接,同一字段循环拼接的全部内容,希望文章能够帮你解决mysql 同一列拼接_mysql 字段值拼接,同一字段循环拼接所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(42)

评论列表共有 0 条评论

立即
投稿
返回
顶部