【发布时间】:2015-07-17 11:52:35
【问题描述】:
我有两张桌子,一张是空的,另一张不是。
- hugot_votes_stats:http://prntscr.com/72ft7d
- hugot_comment_stats:空
我知道我不能使用 Inner JOIN,因为它只会匹配 ON 部分中指定的值。在这种情况下,一张表没有任何价值。
SELECT t0.hugot_id as hugot_id,
t0.upvotes as upvotes,
t1.comment_count as comment_count
FROM
hugot_votes_stats as t0
FULL OUTER JOIN
hugot_comment_stats as t1
ON
t0.hugot_id = t1.hugot_id
这是我想出的使用 FULL JOIN 的部分。我所期望的是,如果没有找到空表(在本例中为 comment_count),它将显示一个默认值(即:0)。
然而,如您所见,我收到了一个错误 1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以了解在附近使用的正确语法
【问题讨论】: