Issue
How can I write this query to a code igniter query?
WHERE
SmallVersion.ID =
(
SELECT ChildSmallVersionID AS ID FROM SmallVersion
WHERE ID = $id
)
this is how is looks so far:
->where('SmallVersion.ID', ("SELECT `ChildSmallVersionID` AS ID
FROM `SmallVersion` WHERE ID = $id"));
Solution
Mateusz Wojtula's answer looks ok but you can protect your query
$strSubQuery = $this->db
->select("ChildSmallVersionID AS ID")
->from("SmallVersion")
->where("ID",$id)
->get_compiled_select();
$where = "SmallVersion.ID = (".$strSubQuery.")";
$this->db->where($where, NULL, FALSE);
Answered By - sintakonte
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.