Can't join the same table twice..


How is it that, when i try to join a table twice, it only joins the second table, and ignores the first one?

This is my code:

$user = self::query()
        ->columns(array('COUNT( as day', 'COUNT(month.month) as month', ''))
        ->join('Blogs', ' = Blogs.userid')

        ->join('Statistics', ' = today.blogid AND = 22', 'today') // THIS get's replaced...
        ->join('Statistics', ' = month.blogid AND month.month = 1', 'month') // THIS works

        ->where(' = :userid:', array('userid' => $id))
        ->orderBy(' DESC')

    return $user;
edited Nov '15

I think they have same name and gets the last of them. Try put an alias to one of them Statistics as S1...

Actually the alias is third param, the first is model, I don't think so S1 will work.


Try turning implicit joins off with the option enable_implicit_joins. You can disable it at the global level or the query level.