客户表:
备注表:
我的SQL查询无效
SELECT * FROM customers LEFT JOIN notes ON customers.customer_id = notes.customer_id GROUP BY notes.customer_id
我想为customer_id 277返回一行: 先生,凯文,新笔记,服务,2017-06-17 12:37:28 新笔记2,Lead,2017-06-17 15:04:42
客户表左连接多表
答案 0 :(得分:0)
您可以在格式化结果上使用group_concat作为笔记
select a.customer_id, a.ttle, a.first_name, group_concat(t.note_row)
from customer
inner join (
select customer_id, concat(note, ' ', note_type, ' ', note_date_added ) as note_row
from notes
) t on t.customer_id = a.customer_id
group by a.customer_id, a.ttle, a.first_name