# Eager loading and :order produces ambiguous column error

**URL:** <https://www.ruby-forum.com/t/eager-loading-and-order-produces-ambiguous-column-error/67574>\
**Category:** Rails\
**Created:** [September 5, 2006, 11:15am UTC](https://www.ruby-forum.com/t/eager-loading-and-order-produces-ambiguous-column-error/67574 "2006-09-05T11:15:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gareth\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@Gareth\_A](https://www.ruby-forum.com/u/Gareth_A)\
**Post date:** [September 5, 2006, 11:15am UTC](https://www.ruby-forum.com/t/eager-loading-and-order-produces-ambiguous-column-error/67574/1 "2006-09-05T11:15:48Z")

</div>

I’m sure I saw a post about this topic a while ago, but I haven’t been  
able to  
find it again.

I have this association:

has\_many :sections, :class\_name =\> “QuestionnaireSection”, :order =\>  
“position”,  
:dependent =\> :destroy, :include =\> :questions

but since the Question object has a position column, the query comes  
back with

Mysql::Error: Column ‘position’ in order clause is ambiguous:

Is there a way to get round this, or do I have to make do with unordered  
questions?

Thanks,  
Gareth

---

<div class="post-metadata">

**Author:** ![Gareth\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@Gareth\_A](https://www.ruby-forum.com/u/Gareth_A)\
**Post date:** [September 7, 2006, 4:11pm UTC](https://www.ruby-forum.com/t/eager-loading-and-order-produces-ambiguous-column-error/67574/2 "2006-09-07T16:11:09Z")

</div>

Gareth A. wrote:

> Mysql::Error: Column ‘position’ in order clause is ambiguous:
> 
> Is there a way to get round this, or do I have to make do with unordered  
> questions?

```
:order => 'questionnaire_sections.position'

```

–  
We develop, watch us RoR, in numbers too big to ignore.

---

<div class="post-metadata">

**Author:** ![Gareth\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@Gareth\_A](https://www.ruby-forum.com/u/Gareth_A)\
**Post date:** [September 8, 2006, 5:06pm UTC](https://www.ruby-forum.com/t/eager-loading-and-order-produces-ambiguous-column-error/67574/3 "2006-09-08T17:06:23Z")

</div>

basically, the problem is the “position” field exists in both tables  
and it’s not sure which one you want to use. that’s why mark’s  
suggestion, which specifies which model to use, should work…
