Trying to join 4 - 5 tables at once as of wanted to grab multiple data which is stored in 5 tables on in 5th table i am trying to count total number of players that have been joined the tournament this is working fine but the main problem which I am facing here is when there is not data in the main table it still return me 1 row with all fields as null except total players showing 0 as it shown not return any rows can anyone help em out below is my query
$getTournamentData = $this->db->select('tournament.*, tournament_meta.meta_title, tournament_meta.meta_description, categories.title AS category, categories.slug AS category_slug, games.game_name, games.slug AS game_slug, count(tournament_players.id) AS total_players');
$getTournamentData = $this->db->join('categories', 'categories.id = tournament.category_id');
$getTournamentData = $this->db->join('games', 'games.game_id = tournament.game_id');
$getTournamentData = $this->db->join('tournament_meta', 'tournament_meta.post_id = tournament.id');
$getTournamentData = $this->db->join('tournament_players', 'tournament_players.tournamentID = tournament.id', 'left');
$dataCond['created_by'] = $this->session->userdata('user_id');
if($id != null) {
$dataCond['tournament.id'] = $id;
}
$getTournamentData = $this->db->where($dataCond);
$getTournamentData = $this->db->get('tournament');
so in return total_players are showing 0 and rest all is null because no data is insterted in the table yet show it should not return any data from the database