codeigniter:列'身份证',才能条款不明确 [英] Codeigniter: Column 'id' in order clause is ambiguous

查看:183
本文介绍了codeigniter:列'身份证',才能条款不明确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用codeIgniter的活动记录类和我使用下面的code检索错误:

I'm using CodeIgniter's Active Record Classes and I'm retrieving an error using the following code:

$this->db->select("*");
$this->db->order_by("id");
$this->db->limit($limit, $offset);
$this->db->from("atoms");
$this->db->join("atommeta", "atommeta.atom_id = atoms.atom_id");

$query  = $this->db->get();

这会产生这个错误:

It produces this error:

Error Number: 1052

Column 'id' in order clause is ambiguous

SELECT * FROM (`atoms`) JOIN `atommeta` ON `atommeta`.`atom_id` = `atoms`.`atom_id` ORDER BY `id` LIMIT 10

Filename: /Applications/MAMP/htdocs/atom/models/atom_model.php

Line Number: 197

197线: $查询= $这个 - > DB->获得();

任何想法,为什么?它似乎有什么东西做与 ORDER_BY

Any ideas as to why? It seems to be something to do with the order_by

推荐答案

该错误意味着您正试图通过用于在多个表中的列名订购。使用具有要通过订购该列的表的名称更新你的 ORDER_BY 语句。例如:

The error means that you are trying to order by a column name that is used in more than one table. Update your order_by statement with the name of the table that has the column you want to order by. For example:

$this->db->order_by('atoms.id');

这篇关于codeigniter:列'身份证',才能条款不明确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆