Welcome Guest, Not a member yet? Register   Sign In
Join Logic
#4

[eluser]ibnclaudius[/eluser]
I don`t want to get the events from the same user_id...

Here what I have:

Code:
$query = $this->db->select($this->_table['events'] . '.id, ' . $this->_table['events'] . '.title, ' . $this->_table['events'] . '.date, ' . $this->_table['users'] . '.username AS user_username, ' . $this->_table['colleges'] . '.username AS college_username')
        ->from($this->_table['events'])
        ->join($this->_table['users_colleges'], $this->_table['users_colleges'] . '.user_id = ' . $user_id, 'INNER')
        ->join($this->_table['colleges'], $this->_table['colleges'] . '.id = ' . $this->_table['events'] . '.college_id AND ' . $this->_table['colleges'] . '.id = ' . $this->_table['users_colleges'] . '.college_id', 'INNER')
        ->join($this->_table['users'], $this->_table['users'] . '.id = ' . $this->_table['events'] . '.user_id', 'INNER')
        ->get();

  if ($query->num_rows() > 0) return $query->result_array();

  return FALSE;

Return this error:

Quote:Unknown column '1' in 'on clause'

SELECT `events`.`id`, `events`.`title`, `events`.`date`, `users`.`username` AS user_username, `colleges`.`username` AS college_username FROM (`events`) INNER JOIN `users_colleges` ON `users_colleges`.`user_id` = `1` INNER JOIN `colleges` ON `colleges`.`id` = `events`.`college_id` AND colleges.id = users_colleges.college_id INNER JOIN `users` ON `users`.`id` = `events`.`user_id`

The problem is with the quotes in 1, without it works... But I don`t know how to remove this ''


Messages In This Thread
Join Logic - by El Forum - 05-23-2012, 02:24 PM
Join Logic - by El Forum - 05-23-2012, 03:36 PM
Join Logic - by El Forum - 05-23-2012, 03:37 PM
Join Logic - by El Forum - 05-23-2012, 04:00 PM
Join Logic - by El Forum - 05-23-2012, 05:46 PM
Join Logic - by El Forum - 05-23-2012, 06:32 PM
Join Logic - by El Forum - 05-23-2012, 06:45 PM
Join Logic - by El Forum - 05-23-2012, 07:05 PM
Join Logic - by El Forum - 05-23-2012, 07:19 PM



Theme © iAndrew 2016 - Forum software by © MyBB