0

How do I write this MySQL query in CodeIgniter?

SELECT *
FROM t1
LEFT JOIN (t2, t3, t4)
ON (t2.a=t1.a AND t3.b=t1.b AND t4.c=t1.c)

1 Answer 1

3

Try this

$this->db->select(*);
$this->db->from('t1');
$this->db->join('t2','t2.a = t1.a','left');
$this->db->join('t3','t3.b = t1.b','left');
$this->db->join('t4','t4.c = t1.c','left');

Alternatively (condensed)

$this->db->select(*)->from('t1')->join('t2','t2.a = t1.a','left')->join('t3','t3.b = t1.b','left')->join('t4','t4.c = t1.c','left');

Reference: http://ellislab.com/codeigniter/user-guide/database/active_record.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.