如何将字符串与多个复杂的 SELECT 语句连接起来并将其放在列中

How to concatinate string with multiple complex SELECT statements and place it in a column

我有一个场景,我想要获取包含以非常特定的方式存储的信息的列。 我想 select n 个来自 table A 的列,连接它们的值,然后添加 m 个更多的值,这些值应该通过加入一个从其他 tables 中获取他们的列到当前语句的列。

假设我们有这些 table,我们要做的是将以下信息放在一列中:

'car_id, brand_name, year_of_release, plate_id, model_name, car_owner_name, registration_state'

对于汽车的每一行 table 作为“custom_column”值

我希望它是一个逗号分隔的字符串。有没有办法用 MySQL 做到这一点?

你似乎想要concat_ws():

select concat_ws(', ', car_id, brand_name, year_of_release, plate_id, model_name, car_owner_name, registration_state)
from t;