I've a simple question: how can I use CodeIgniter's ActiveRecord join
function? I want this:
LEFT JOIN cimke ON (mk_terem.id_kicsoda=5 AND mk_terem.id_target=cimke.id_cimke)
LEFT JOIN tanar ON (mk_terem.id_kicsoda=1 AND mk_terem.id_target=tanar.id_tanar)
But if I use $this->db->join(cimke,"mk_terem.id_kicsoda=5 AND mk_terem.id_target=cimke.id_cimke")
, the value 5
will be between backticks.
How can I do this?
UPDATE
What I want? If mk_terem.id_kicsoda
is 1, then I want tanar.nev
and when mk_terem.id_kicsoda
is 5, I want cimke.nev
.
The full SQL-query:
SELECT
terem.nev terem_nev,
elem_tipus.nev tipus_nev,
(IFNULL(cimke.nev,tanar.nev)) nev
FROM mk_terem
LEFT JOIN terem ON mk_terem.id_terem=terem.id_terem
LEFT JOIN cimke ON (mk_terem.id_kicsoda=5 AND mk_terem.id_target=cimke.id_cimke)
LEFT JOIN tanar ON (mk_terem.id_kicsoda=1 AND mk_terem.id_target=tanar.id_tanar)
LEFT JOIN elem_tipus ON (mk_terem.id_kicsoda=elem_tipus.id_kicsoda)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…