0

I don't understand how to convert this query into codeigniter linq

SELECT prdctSubCatId 
FROM productinfo 
WHERE prdctSubCatId = (
  SELECT prdctSubCatId 
  FROM productinfo 
  WHERE id='27'

) Instead of id ='27' I want to pass id=$id, then how can I do this

1
  • I think @Nithin Krishnan P's answer is what you want. If your CI version is 3 you can do it alternative way using get_compiled_select Commented Jun 29, 2015 at 10:07

3 Answers 3

1
$this->db->select('prdctSubCatId')->from('productinfo');
$this->db->where('`prdctSubCatId`= (SELECT `prdctSubCatId` FROM `productinfo` WHERE id=27 )', NULL, FALSE);
1
    $this->db->select('prdctSubCatId');
    $this->db->where('id',27);
    return $this->db->get('productinfo')->result_array();
0

Simply use

$query = $this->db->query("SELECT prdctSubCatId FROM productinfo WHERE prdctSubCatId=27");
$result = $query->result_array();
return $result;
0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.