F
F
FlapJalc2017-11-16 15:25:04
MySQL
FlapJalc, 2017-11-16 15:25:04

Why doesn't joining tables via JOIN work?

What am I doing no??? There are 2 tables: the first contains cities with names, and the second contains the identifiers of these cities. Why does fetching from the database stop working after adding a JOIN? What am I doing wrong here? Without using JOIN, the selection works fine, but with use, it does not display anything.

<?php
defined('_JEXEC') or die;

class bh_programsModelWorldrating extends JModelList {

  protected function getListQuery()
    {
    $query = parent::getListQuery();

    $query->select($this->getState('a','id, name, worldrating, city_id'));

    $query->from('#__bh_program_schools AS ps');
    $query->where('worldrating_rank > 0');

    $query->select('pc.name AS city_name');
    $query->join('LEFT', '#__bh_program_cities AS pc ON pc.id = ps.city_id');


    return $query;

  }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question