Php Codeigniter中左侧联接的空结果

Php Codeigniter中左侧联接的空结果,php,mysql,codeigniter,Php,Mysql,Codeigniter,因此,我试图从我的数据库中查找上个月在另一个表中没有任何行的用户,尽管看起来我的查询是正确的;我得到的结果是空的 public function __construct() { parent::__construct(); //Set Payment Dates $this->dates = array('1st', '8th', '15th', '25th'); //Which Month do the figures

因此,我试图从我的数据库中查找上个月在另一个表中没有任何行的用户,尽管看起来我的查询是正确的;我得到的结果是空的

public function __construct() {
        parent::__construct();

        //Set Payment Dates
        $this->dates = array('1st', '8th', '15th', '25th');

        //Which Month do the figures need submitting as
        $this->monthPrev    = date('F Y', strtotime(date('F Y')." -1 month"));
        $this->currentMonth = date('F Y', strtotime('this month'));
    }

public function getUnreportedQuarterlies()
    {
        $this->db->select('quarterly_figures.month, quarterly_figures.centre, users.name, users.email');
        $this->db->from('quarterly_figures');
        $this->db->join('users', 'users.name = quarterly_figures.centre', 'left');
        $this->db->where("quarterly_figures.month", $this->monthPrev);
        $this->db->where("quarterly_figures.centre IS NULL");
        return $this->db->get()->result();
    }
我的数据库行如下所示:

使用者

季度统计数字


“用户”表与“季度数字”表没有关系,如果没有关系,则无法返回数据。您可以在每个输入的“季度数字”中插入users.id。

这肯定是不正确的,因为您检查的是左表中的空条件,而不是右表中的空条件。您的描述不清楚,因此我无法真正判断您是否混淆了联接的各个方面,或者只是在错误的表上进行了筛选。@Shadow raw SQL是我的难点,我基本上只需要检索所有用户。根据提供的季度数字,在季度数字表中没有行的名称。month激活上面的数据集,期望的结果应该是什么样的?然后你把表的顺序弄混了。使用右联接或更改联接中表的顺序。
CREATE TABLE `users` (
  `id` int(11) NOT NULL,
  `name` varchar(45) DEFAULT NULL,
  `email` varchar(45) DEFAULT NULL,
  `password` varchar(45) DEFAULT NULL,
  `address` varchar(45) DEFAULT NULL,
  `owners_password` varchar(45) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

INSERT INTO `users` (`id`, `name`, `email`, `password`, `address`, `owners_password`) VALUES
(1, 'Aldridge', 'aldridge@website.co.uk', 'password', '127.0.0.1', 'password');
CREATE TABLE `quarterly_figures` (
  `id` int(11) NOT NULL,
  `centre` varchar(45) DEFAULT NULL,
  `month` varchar(45) DEFAULT NULL,
  `date` date DEFAULT NULL,
  `direct_debits` varchar(45) DEFAULT NULL,
  `money_paid` varchar(45) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

INSERT INTO `quarterly_figures` (`id`, `centre`, `month`, `date`, `direct_debits`, `money_paid`) VALUES
(1, 'Rugby', 'January 2019', '2019-01-01', '128', '3519.00');