mysql回行_Mysql返回多行

我有这个问题.

SELECT notes.id,enter.name as 'enter_name',step.title as 'flow status',notes.user_name as user_created,notes.created,notes.rel_client_id,td_doc_nr.value_string as 'document number',enter.enter_code,

IF(!ISNULL(td_doc_nr.value_string),

(SELECT GROUP_CONCAT(product_name SEPARATOR ',') from notes d

join note_bundles b on b.note_id = d.id

join note_products p on p.doc_bundle_id = b.id

join note_product_get_fields f on f.doc_product_id = p.id

join note_product_get_field_data fd on fd.get_field_id = f.id

where d.doc_nr = td_doc_nr.value_string

and value_string ='auto')

,NULL) as test

FROM notes notes

JOIN notes_steps step ON step.id = notes.step_id

JOIN notes_enters enter ON enter.id = notes.enter_id

LEFT JOIN notes_custom_fields tf_doc_nr ON tf_doc_nr.name = 'note_number' AND tf_doc_nr.rel_entity_id = enter.id

LEFT JOIN notes_custom_field_data td_doc_nr ON td_doc_nr.rel_entity_id = notes.id AND

td_doc_nr.field_instance_id = tf_doc_nr.id

WHERE notes.enter_id in (777) AND notes.status = 1

我将此子查询添加到’if语句’

SELECT GROUP_CONCAT(product_name SEPARATOR ',') from nontes d

join note_bundles b on b.note_id = d.id

join note_products p on p.doc_bundle_id = b.id

join note_product_get_fields f on f.doc_product_id = p.id

join note_product_get_field_data fd on fd.get_field_id = f.id

where d.doc_nr = 'G7777777'

and value_string ='auto'

在此之后我添加了一个新专栏.

SELECT GROUP_CONCAT(product_name SEPARATOR ','),GROUP_CONCAT(DISTINCT b.msisdn SEPARATOR ',') from notes d

join note_bundles b on b.note_id = d.id

join note_products p on p.doc_bundle_id = b.id

join note_product_get_fields f on f.doc_product_id = p.id

join note_product_get_field_data fd on fd.get_field_id = f.id

where d.doc_nr = 'G7777777'

and value_string ='auto'

它返回两列.

如何返回两列?有可能吗? :) 谢谢

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值