我有两张表,其结构如下
Table name = counter
ref_id INT NOT NULL
count INT NOT NULL
Table name = favs
disqus_id VARCHAR(32) NOT NULL
user_id INT NOT NULL
dormant VAHCHAR(10) NOT NULL
我运行这个查询 =>SELECT count, dormant FROM counter AS c LEFT JOIN favs AS f ON c.ref_id = f.disqus_id WHERE ref_id = 'post_5' AND user_id = '1'.
但如果在第二个表中找不到匹配项,它不会返回任何行favs
。我想要的是,如果找到结果,它应该返回两列,否则返回两列,第二列是NULL
我该怎么做呢?