title: Error 1054 after start fetching on MySQL Workbench
body: <p>My query had 3 <code>UNION</code> working, and I need to add a fourth one.</p>
  
  <p>The query is:</p>
  
  <pre><code>SELECT SQL_CACHE posts.*
                  FROM (
  
                      SELECT posts.id, posts.text, posts.image, posts.date, posts.status, posts.location as postLocation, posts.user AS user, users.name, users.username, users.photo, users.location,users.bio, users.background, groups_posts.group as groupId, null as groupName, sum(r.rating) as rating
                      ,(
                          select count(re.id ) 
                          FROM relations re
                          WHERE re.user = users.id
                      ) as numfollowing,
                      (
                          select count(re.id ) 
                          FROM relations re
                          WHERE re.friend = users.id
                      ) as numfollowers,
                      (
                          select count(re.id)
                          FROM relations re
                          where re.friend = users.id
                          AND re.user = 24527
                      ) as following,
                      (
                          select count(c.id) 
                          from comments c 
                          where c.post = posts.id AND c.user NOT IN (
                              select users.id from users where users.status = 3 OR users.status = 4
                          )
                      ) as numcomments,
                      ifnull(ru.rating, 0)  as myrating
  
  
                      FROM `relations`
                      JOIN `posts` ON relations.friend = posts.user
                      JOIN `users` ON relations.friend = users.id
                      LEFT JOIN `groups_posts` ON posts.id = groups_posts.post
                      LEFT JOIN ratings r ON r.post = posts.id 
                      LEFT JOIN ratings ru ON ru.post = posts.id and ru.user = 24527
                      WHERE relations.user = '24527' 
                          AND groups_posts.group is NULL
                          AND posts.status != 1 AND posts.status != 5
                          AND posts.date &gt;= DATE_SUB(CURDATE(), INTERVAL 30 DAY)
                          GROUP BY posts.id
                      UNION
  
                      SELECT posts.id, posts.text, posts.image, posts.date, posts.status, posts.location as postLocation, posts.user AS user, users.name, users.username, users.photo, users.location, users.bio, users.background, null as groupId, null as groupName, sum(r.rating) as rating
                      ,(
                          select count(re.id ) 
                          FROM relations re
                          WHERE re.user = users.id
                      ) as numfollowing,
                      (
                          select count(re.id ) 
                          FROM relations re
                          WHERE re.friend = users.id
                      ) as numfollowers,
                      (
                          select count(re.id)
                          FROM relations re
                          where re.friend = users.id
                          AND re.user = 24527
                      ) as following,
                      (
                          select count(c.id) 
                          from comments c 
                          where c.post = posts.id AND c.user NOT IN (
                              select users.id from users where users.status = 3 OR users.status = 4
                          )
                      ) as numcomments,
                      ifnull(ru.rating, 0)  as myrating
                      FROM `posts`
                      JOIN `users` ON posts.user = users.id
                      LEFT JOIN `groups_posts` ON posts.id = groups_posts.post
                      LEFT JOIN ratings r ON r.post = posts.id 
                      LEFT JOIN ratings ru ON ru.post = posts.id and ru.user = 24527
                      WHERE posts.user = '24527'
                          AND groups_posts.group IS NULL
                          AND posts.status != 1 AND posts.status != 5
                          AND posts.date &gt;= DATE_SUB(CURDATE(), INTERVAL 30 DAY)
                          GROUP BY posts.id
                      UNION
  
                      SELECT posts.id, posts.text, posts.image, posts.date, posts.status, posts.location as postLocation, posts.user AS user, users.name, users.username, users.photo, users.location, users.bio, users.background, groups.id as groupId, groups.name as groupName, sum(r.rating) as rating
                      ,(
                          select count(re.id ) 
                          FROM relations re
                          WHERE re.user = users.id
                      ) as numfollowing,
                      (
                          select count(re.id ) 
                          FROM relations re
                          WHERE re.friend = users.id
                      ) as numfollowers,
                      (
                          select count(re.id)
                          FROM relations re
                          where re.friend = users.id
                          AND re.user = 24527
                      ) as following,
                      (
                          select count(c.id) 
                          from comments c 
                          where c.post = posts.id AND c.user NOT IN (
                              select users.id from users where users.status = 3 OR users.status = 4
                          )
                      ) as numcomments,
                      ifnull(ru.rating, 0)  as myrating
                      FROM groups_members 
                      JOIN groups ON groups_members.group = groups.id
                      JOIN groups_posts ON groups_members.group = groups_posts.group
                      JOIN posts ON groups_posts.post = posts.id
                      JOIN users ON posts.user = users.id
                      LEFT JOIN ratings ru ON ru.post = posts.id and ru.user = 24527
                      LEFT JOIN ratings r ON r.post = posts.id 
                      WHERE groups_members.member = '24527'
                          AND groups_members.subscription = '1'
                          AND groups.status = '1'
                          AND posts.status != 1 AND posts.status != 5
                          AND posts.date &gt;= DATE_SUB(CURDATE(), INTERVAL 30 DAY)
                      GROUP BY posts.id
                      UNION 
  
  
  
     -- I need to add the SELECT below
  
                      SELECT companies_posts.id as `posts.id`, 
                      companies_posts.text as `posts.text`, 
                      companies_posts.image as `posts.image`,
                      companies_posts.date as `posts.date`, 
                      companies_posts.status as `posts.status`, 
                      null as postLocation,
                       companies_posts.company AS user, 
                      companies.name as `users.name`, 
                      companies.username as `users.username`, 
                      companies.photo as `users.photo`, 
                      null as `users.location`, 
                      companies.description as `users.bio`, 
                      companies.cover as `users.cover`, 
                      null as groupId, 
                      null as groupName, 
                      null as rating,
                      null as numfolllowing,
                      null as numfollowers,
                      null as following,
                      null as myrating,
                      null as numcomments
  
  
  
                      FROM `companies_subscriptions`
                      JOIN `companies_posts` ON companies_subscriptions.user = user
                      JOIN `companies` ON companies_subscriptions.company = companies.id
                      WHERE companies_subscriptions.user = '24527' 
                          AND companies_posts.status != 1 AND companies_posts.status != 5
                          AND companies_posts.date &gt;= DATE_SUB(CURDATE(), INTERVAL 30 DAY)
                          GROUP BY companies_posts.id
                          ORDER BY posts.date DESC, groupId DESC
  
  
  
                  ) as posts
  
                  LEFT JOIN users_blocked ON (users_blocked.user = posts.user AND users_blocked.blocked_friend = 24527) OR (users_blocked.user = 24527 AND users_blocked.blocked_friend = posts.user)
                  WHERE 
                      users_blocked.user IS  NULL
                  AND users_blocked.blocked_friend IS  NULL
                  GROUP BY posts.id
                  ORDER BY posts.date DESC
  
                  LIMIT 0, 10
  </code></pre>
  
  <p>After fix a lot of errors, it is fetching... but returns me an error 1054 while fetch, as described on image below:</p>
  
  <p><img src="https://i.stack.imgur.com/NDuqv.png" alt="enter image description here">
  What's happening?</p>