mysql(5.1.36)中关于全连接的问题很多。当然,解决方案是加入工会组合。
我的问题是我有两个这样的临时表:
CREATE TEMPORARY TABLE wConfs
(
idWorker INT,
confs SMALLINT
) ENGINE=INNODB;
CREATE TEMPORARY TABLE wRejects
(
idWorker INT,
rejects SMALLINT
) ENGINE=INNODB;
JOIN-UNION mix 不能用于完全连接临时表,因为它会导致ERROR 1137 (HY000): Can't reopen table
.
我的问题是——在临时表上实现完全连接的最简单的解决方案是什么?
编辑:加入联合组合:
SELECT wc.idWorker, wc.confs, wr.rejects FROM wConfs wc LEFT JOIN wRejects wr
ON (wr.idWorker = wc.idWorker)
UNION
SELECT wc.idWorker, wc.confs, wr.rejects FROM wConfs wc RIGHT JOIN wRejects wr
ON (wr.idWorker = wc.idWorker);