Note that there are some explanatory texts on larger screens.

plurals
  1. POThe used SELECT statements have a different number of columns (REDUX!!)
    primarykey
    data
    text
    <p>There's another question out there similar to this, but it didn't seem to answer <em>my</em> question.</p> <p>My question is this: why am I getting back this error <code>ERROR 1222 (21000): The used SELECT statements have a different number of columns</code> from the following SQL </p> <pre><code>SELECT * FROM friends LEFT JOIN users AS u1 ON users.uid = friends.fid1 LEFT JOIN users AS u2 ON users.uid = friends.fid2 WHERE (friends.fid1 = 1) AND (friends.fid2 &gt; 1) UNION SELECT fid2 FROM friends WHERE (friends.fid2 = 1) AND (friends.fid1 &lt; 1) ORDER BY RAND() LIMIT 6; </code></pre> <p>Here's <code>users</code>:</p> <pre><code>+------------+---------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+---------------+------+-----+---------+----------------+ | uid | int(11) | NO | PRI | NULL | auto_increment | | first_name | varchar(50) | NO | | NULL | | | last_name | varchar(50) | NO | | NULL | | | email | varchar(128) | NO | UNI | NULL | | | mid | varchar(40) | NO | | NULL | | | active | enum('N','Y') | NO | | NULL | | | password | varchar(64) | NO | | NULL | | | sex | enum('M','F') | YES | | NULL | | | created | datetime | YES | | NULL | | | last_login | datetime | YES | | NULL | | | pro | enum('N','Y') | NO | | NULL | | +------------+---------------+------+-----+---------+----------------+ </code></pre> <p>Here's <code>friends</code>:</p> <pre><code>+---------------+--------------------------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------+--------------------------------------+------+-----+---------+----------------+ | friendship_id | int(11) | NO | MUL | NULL | auto_increment | | fid1 | int(11) | NO | PRI | NULL | | | fid2 | int(11) | NO | PRI | NULL | | | status | enum('pending','accepted','ignored') | NO | | NULL | | +---------------+--------------------------------------+------+-----+---------+----------------+ </code></pre> <p>If you want to give any feedback on anything crazy you see going on here, as well, please feel free to do so. I'll take my lumps.</p>
    singulars
    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.
 

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