MySQL合并查询到的相同字段的值

时间:2021-10-02 10:30:07
select concat_ws('</div><div>',car_brand.name,car_model.name) as name,car_discount.id,car_discount.title 
from car_model left join car_brand on car_brand.id=car_model.brand 

left join car_discount on car_discount.model=car_model.id where car_discount.seller = '56372f158822b425';


MySQL合并查询到的相同字段的值

concat_ws('</div><div>',car_brand.name,car_model.name) as name

将查询到的car_brand.name,car_model.name的两个name字段合并。


MySQL字段合并函数的使用:

CONCAT(str1,str2,…) 

CONCAT_WS(separator,str1,str2,...)

GROUP_CONCAT ( name )