Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can <code>JOIN</code> two selects with each other and then perform <code>COALESCE</code> on columns.</p> <p><a href="http://www.sqlfiddle.com/#!2/bfcd8/15" rel="nofollow">http://www.sqlfiddle.com/#!2/bfcd8/15</a></p> <pre><code>SELECT app_id,transaction_id,mobile_no, coalesce(tt1.USER_INPUT1,tt2.USER_INPUT1) AS USER_INPUT1, coalesce(tt1.USER_INPUT3,tt2.USER_INPUT3) AS USER_INPUT3, coalesce(tt1.USER_INPUT17,tt2.USER_INPUT17) AS USER_INPUT17, coalesce(tt1.USER_INPUT110,tt2.USER_INPUT110) AS USER_INPUT110, coalesce(tt1.USER_INPUT61,tt2.USER_INPUT61) AS USER_INPUT61, coalesce(tt1.USER_INPUT62,tt2.USER_INPUT62) AS USER_INPUT62 FROM (SELECT T1.app_id, T1.transaction_id, T1.mobile_no, CONVERT( GROUP_CONCAT( (CASE T1.node_id WHEN 103 THEN CONCAT(T1.customer_attribute, '~', T2.display_text) ELSE NULL END)) USING LATIN1) AS user_input1, CONVERT( GROUP_CONCAT( (CASE T1.node_id WHEN 105 THEN CONCAT(T1.customer_attribute, '~', T2.display_text) ELSE NULL END)) USING LATIN1) AS user_input3, CONVERT( GROUP_CONCAT( (CASE T1.node_id WHEN 119 THEN CONCAT(T1.customer_attribute, '~', T2.display_text) ELSE NULL END)) USING LATIN1) AS user_input17, CONVERT( GROUP_CONCAT( (CASE T1.node_id WHEN 121 THEN CONCAT(T1.customer_attribute, '~', T2.display_text) ELSE NULL END)) USING LATIN1) AS user_input110, CONVERT( GROUP_CONCAT( (CASE T1.node_id WHEN 169 THEN CONCAT(T1.customer_attribute, '~', T2.display_text) ELSE NULL END)) USING LATIN1) AS user_input61, CONVERT( GROUP_CONCAT( (CASE T1.node_id WHEN 170 THEN CONCAT(T1.customer_attribute, '~', T2.display_text) ELSE NULL END)) USING LATIN1) AS user_input62 FROM trn_user_log T1 INNER JOIN mst_node T2 ON T1.APP_ID = T2.APP_ID WHERE T1.app_id = 104 AND T1.transaction_id = 731 AND T1.node_id = T2.parent_node_id AND T2.`display_seq` = T1.entered_value -- GROUP BY T1.app_id, T1.transaction_id, T1.mobile_no -- ORDER BY T1.node_id ) AS tt1 LEFT JOIN (SELECT T3.app_id, T3.transaction_id, T3.mobile_no, CONVERT( GROUP_CONCAT( (CASE T3.node_id WHEN 103 THEN CONCAT(T3.customer_attribute, '~', T3.entered_value) ELSE NULL END)) USING LATIN1) AS user_input1, CONVERT( GROUP_CONCAT( (CASE T3.node_id WHEN 105 THEN CONCAT(T3.customer_attribute, '~', T3.entered_value) ELSE NULL END)) USING LATIN1) AS user_input3, CONVERT( GROUP_CONCAT( (CASE T3.node_id WHEN 119 THEN CONCAT(T3.customer_attribute, '~', T3.entered_value) ELSE NULL END)) USING LATIN1) AS user_input17, CONVERT( GROUP_CONCAT( (CASE T3.node_id WHEN 121 THEN CONCAT(T3.customer_attribute, '~', T3.entered_value) ELSE NULL END)) USING LATIN1) AS user_input110, CONVERT( GROUP_CONCAT( (CASE T3.node_id WHEN 169 THEN CONCAT(T3.customer_attribute, '~', T3.entered_value) ELSE NULL END)) USING LATIN1) AS user_input61, CONVERT( GROUP_CONCAT( (CASE T3.node_id WHEN 170 THEN CONCAT(T3.customer_attribute, '~', T3.entered_value) ELSE NULL END)) USING LATIN1) AS user_input62 FROM trn_user_log T3 INNER JOIN mst_node T4 ON T3.APP_ID = T4.APP_ID WHERE T3.app_id = 104 AND T3.transaction_id = 731 AND T3.node_id = T4.node_id AND NOT EXISTS (SELECT 1 FROM mst_node b WHERE b.parent_node_id = t4.node_id) -- GROUP BY T3.app_id, T3.transaction_id, T3.mobile_no -- ORDER BY T3.node_id ) AS tt2 USING (app_id, transaction_id, mobile_no) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload