我不明白如何将此查询转换为codeigniter linq
SELECT prdctSubCatId
FROM productinfo
WHERE prdctSubCatId = (
SELECT prdctSubCatId
FROM productinfo
WHERE id='27'
) 而不是id = '27'我想传递id = $ id,那我该怎么做呢
答案 0 :(得分:1)
$this->db->select('prdctSubCatId')->from('productinfo');
$this->db->where('`prdctSubCatId`= (SELECT `prdctSubCatId` FROM `productinfo` WHERE id=27 )', NULL, FALSE);
答案 1 :(得分:1)
$this->db->select('prdctSubCatId');
$this->db->where('id',27);
return $this->db->get('productinfo')->result_array();
答案 2 :(得分:0)
只需使用
$query = $this->db->query("SELECT prdctSubCatId FROM productinfo WHERE prdctSubCatId=27");
$result = $query->result_array();
return $result;