Welcome Guest, Not a member yet? Register   Sign In
CI join and
#1

[eluser]Lachiaso[/eluser]
Dear all,

I want to translate the following Mysql to Codigniter

Code:
INNER JOIN
table AS o
ON
  cl.client_id = o.suplier_id
AND
  o.day_id = " . GetDayId() . "

I know that join function of CI is:

Code:
$this->db->join('comments', 'comments.id = blogs.id', 'left');

// Produces: LEFT JOIN comments ON comments.id = blogs.id

but how to add AND into this ?

BTW: i know the www ;-)
#2

[eluser]Otemu[/eluser]
Hi,

Just add a where clause
Code:
$this->db->join('comments', 'comments.id = blogs.id', 'left');
$this->db->where('o.day_id', GetDayId());
#3

[eluser]TheFuzzy0ne[/eluser]
This might work:
Code:
$this->db->join('comments', 'comments.id = blogs.id AND o.day_id = '. GetDayId(), 'inner');




Theme © iAndrew 2016 - Forum software by © MyBB