Access数据库的Codeigniter限制

时间:2012-07-18 14:23:35

标签: sql codeigniter ms-access activerecord

我有以下“Active Record”设置:

$this->db->select('*');
$this->db->from('Orders');
$this->db->join('MPC_Agents', 'Orders.UserName = MPC_Agents.UserName', 'inner');    
$this->db->limit(50,20);
$query = $this->db->get();

使用$this->db->last_query(); mereley输出:

SELECT * FROM (Orders) INNER JOIN MPC_Agents ON Orders.UserName = MPC_Agents.UserName

为什么不适用这个限制?

2 个答案:

答案 0 :(得分:1)

MS Access SQL中没有限制。您可以选择Top:

SELECT Top 10 Id FROM Table Order BY Id

SELECT Top 10 Id FROM Table 
WHERE ID Not IN (SELECT Top 10 ID From Table ORDER BY Id)
Order BY Id

答案 1 :(得分:0)

将您的限制放在查询的顶部并编辑为

 $this->db->limit(20,50);
 $this->db->select('*');
 $this->db->from('Orders');
 $this->db->join('MPC_Agents', 'Orders.UserName = MPC_Agents.UserName', 'inner');
 $this->db->get();

希望它能更好地运作