title: Combine multiple MySQL queries returning different columns
body: <p>I'm getting data from 4 different tables using 3 different mysql queries and JOINS.</p>
  
  <p>MySQL Query 1</p>
  
  <pre><code>SELECT tb1.request_item_id AS most_requested_item_id, tb2.item_name AS most_requested_item_name
  FROM  `requests` tb1 
  LEFT JOIN `items` tb2 ON tb1.request_item_id = tb2.item_id
  GROUP BY tb1.request_item_id
  ORDER BY COUNT(*) DESC
  LIMIT 3
  </code></pre>
  
  <p>Query 1 Output </p>
  
  <pre><code>  most_requested_item_id | most_requested_item_name
           87              | Poster FLS
           95              | Sample Item 4
           89              | Earth
  </code></pre>
  
  <p>Query 2</p>
  
  <pre><code>  SELECT tb1.user_credit AS highest_credit_value, tb1.user_full_name AS highest_credit_user 
    FROM users tb1 
    ORDER BY tb1.user_credit 
    DESC LIMIT 3
  </code></pre>
  
  <p>Query 2 output</p>
  
  <pre><code>   highest_credit_value | highest_credit_user
            140           | User A
            11            | User B
            10            | User C
  </code></pre>
  
  <p>Query 3</p>
  
  <pre><code>SELECT tb1.credit_user_id AS credit_monthly_user, 
         SUM(tb1.credit_amount) AS totalCredit_monthly, 
         tb2.user_full_name AS monthly_credit_user 
  FROM `credit_log` tb1 
  LEFT JOIN users tb2 ON tb1.credit_user_id = tb2.user_id 
  WHERE tb1.credit_date BETWEEN (CURDATE() - INTERVAL 30 DAY) AND CURDATE() 
  GROUP BY credit_user_id 
  ORDER BY totalCredit_monthly DESC 
  LIMIT 3
  </code></pre>
  
  <p>Query 3 Output</p>
  
  <pre><code>     credit_monthly_user | totalCredit_monthly Descending 1 | monthly_credit_user
       User C              | 350                              | User D
       User E              | 170                              | User F
       User G              | 70                               | User H
  </code></pre>
  
  <p>My SQL query</p>
  
  <pre><code>(SELECT tb1.request_item_id AS most_requested_item_id, tb2.item_name AS most_requested_item_name
  FROM  `requests` tb1 LEFT JOIN `items` tb2
  ON tb1.request_item_id = tb2.item_id
  GROUP BY tb1.request_item_id
  ORDER BY COUNT(*) DESC
  LIMIT 3)
  UNION
  (SELECT tb1.user_credit AS highest_credit_value, tb1.user_full_name AS highest_credit_user
  FROM users tb1
  ORDER BY tb1.user_credit DESC
  LIMIT 3)
  UNION
  (SELECT tb1.credit_user_id AS credit_monthly_user, SUM(tb1.credit_amount) AS totalCredit_monthly, tb2.user_full_name AS monthly_credit_user
  FROM `credit_log` tb1 LEFT JOIN users tb2 
  ON tb1.credit_user_id = tb2.user_id
  WHERE tb1.credit_date
  BETWEEN (CURDATE() - INTERVAL 30 DAY) AND CURDATE()
  GROUP BY credit_user_id 
  ORDER BY totalCredit_monthly 
  DESC LIMIT 3) 
  </code></pre>
  
  <p><strong>Desired Output</strong></p>
  
  <pre><code>   most_requested_item_id | most_requested_item_name | highest_credit_value | highest_credit_user | credit_monthly_user | totalCredit_monthly Descending 1 | monthly_credit_user
            87              | Poster FLS               | 140                  | User A              |  User C             | 350                              | User D
            95              | Sample Item 4            | 11                   | User B              | User E              | 170                              | User F
            89              | Earth                    | 10                   | User C              | User G              | 70                               | User H  
  </code></pre>
  
  <p>But I get an error:</p>
  
  <blockquote>
    <p>The used select statements have a different number of columns union</p>
  </blockquote>
  
  <p>Schema of table <strong>credit_log</strong></p>
  
  <pre><code>  Field         | Type         | Null | Key | Default| Extra
    credit_log_id | int(11)      | NO   | PRI | NULL   | auto_increment
    credit_user_id| varchar(255) | YES  |     | NULL   |
    credit_date   | datetime     | YES  |     | NULL   |
    credit_amount | int(11)      | YES  |     | NULL   |
    credit_type   | varchar(255) | YES  |     | NULL   |
    credit_desc   | varchar(255) | YES  |     | NULL   |
  </code></pre>
  
  <p>Schema of table <strong>requests</strong></p>
  
  <pre><code>  Field                | Type         | Null | Key | Default           | Extra
    request_id           | int(11)      | NO   | PRI | NULL              |  auto_increment
    request_requser_id   | varchar(255) | NO   | PRI
    request_item_id      | varchar(255) | NO   | PRI
    request_status       | varchar(20)  | NO   |     | Active
    request_lastmodified | datetime     | NO   |     | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP
    request_message      | varchar(225) | YES  |     | NULL
  </code></pre>
  
  <p>Schema of table <strong>items</strong></p>
  
  <pre><code>  Field                   | Type         | Null | Key     | Default           | Extra
    item_id                 | int(11)      | NO   | PRI     | NULL              | auto_increment
    item_name               | varchar(255) | NO   |         | NULL
    item_category           | varchar(255) | NO   |         | NULL
    item_desc               | varchar(255) | YES  |         | NULL
    item_user_id            | varchar(255) | YES  |         | NULL
    item_lease_value        | int(11)      | YES  |         | NULL
    item_lease_term         | varchar(255) | YES  |         | NULL
    item_image              | mediumtext   | YES  |         | NULL
    item_primary_image_link | varchar(255) | YES  |         | NULL
    item_status             | varchar(255) | NO   | Created |
    item_uid                | varchar(255) | YES  |         | NULL
    item_lat                | float(10,6)  | YES  |         | NULL
    item_lng                | float(10,6)  | YES  |         | NULL
    item_lastmodified       | datetime     | NO             | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP
  </code></pre>
  
  <p>Schema of table <strong>users</strong>.</p>
  
  <p><a href="https://i.stack.imgur.com/v02QD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v02QD.jpg" alt="users_table"></a></p>
  
  <p>Is there any way of combining the above 3 queries into one so that it returns total 7 columns?? Please help</p>