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'

Возвращает два столбца. Как вернуть два столбца? Возможно ли это? :) Спасибо

8
задан Oyeme 11 September 2012 в 11:35
поделиться