我有一个查询
SELECT l.id,l.name,l.city,l.email,l.phone,l.status,l.source,l.leadCreatedTime,l.organizationId
FROM (
SELECT id
FROM leads
where removed='0'
ORDER BY
id
LIMIT 40000
) o
JOIN leads l
ON l.id = o.id
ORDER BY
l.id
我想以Codeigniter格式转换此查询,例如
$this->db->select('l.id,l.name,l.city,l.email,l.phone,l.status,l.source,l.leadCreatedTime,l.organizationId');
$this->db->from('leads');
我在第8行查询中遇到问题,其中获取的数据被定义为o我如何在CI中写入
答案 0 :(得分:2)
你可以测试我的代码,它可以帮助你,因为它是codeigniter格式
$this->db- >select('l.id,l.name,l.city,l.email,l.phone,l.status,l.source,l.leadCreatedTime,l.organizationId');
$this->db->from('(SELECT id FROM leads where removed="0" ORDER BY id LIMIT 40000) o');
$this->db->join('leads l', 'l.id = o.id');
$this->db->order_by('l.id');
$result=$this->db->get();
$show=$result->result_array();
它不是在子查询中的完全codeigniter格式,但它可以帮助你。
享受代码。
答案 1 :(得分:0)
今年五月适合你:
$this->db->select('l.id,l.name,l.city,l.email,l.phone,l.status,l.source,l.leadCreatedTime,l.organizationId');
$this->db->from('leads o');
$this->db->join('leads l', 'l.id = o.id');
$this->db->order_by("l.id", "asc");
$q = $this->db->get();