Re: PGError: ERROR: missing FROM-clause entry for table

From: Robert Treat <rob(at)xzilla(dot)net>
To: byrnejb(at)harte-lyne(dot)ca
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: PGError: ERROR: missing FROM-clause entry for table
Date: 2010-11-26 02:58:18
Message-ID: AANLkTi=FY=tOjgF=YPmCuFAsMkt=rbajo6z761bi+Dnv@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Nov 25, 2010 at 9:21 PM, James B. Byrne <byrnejb(at)harte-lyne(dot)ca>wrote:

> I am getting this error:
>
> PGError: ERROR: missing FROM-clause entry for table "ca_customs_entry"
> LINE 1: ..._entries"."is_cadex_transmitted" = 'f') ORDER BY
> ca_customs...
>
> The code is generated by a Ruby-on-Rails-3.0.1 ActiveRecord model:
>
> SELECT "ca_customs_shipments".* FROM "ca_customs_shipments" INNER
> JOIN "ca_customs_entries" ON
> "ca_customs_entries"."ca_customs_shipment_id" =
> "ca_customs_shipments"."id" WHERE
> ("ca_customs_entries"."is_cadex_transmitted" = 'f') ORDER BY
> ca_customs_entry.is_across_transmitted,
> ca_customs_entry.is_across_rejected,
> ca_customs_entry.is_across_accepted,
> ca_customs_entry.is_cadex_released LIMIT 5 OFFSET 0
>

Looks to me like the problem is you are trying to ORDER BY columns in
"ca_customs_entry", but there is no such table for that (don't confuse it
with "ca_customs_entries"). You need to either set a matching alias, or fix
the table name qualifier in those order by columns.

Robert Treat
play: xzilla.net
work: l42.org/lg

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message James B. Byrne 2010-11-26 03:13:40 Re: PGError: ERROR: missing FROM-clause entry for table
Previous Message James B. Byrne 2010-11-26 02:21:13 PGError: ERROR: missing FROM-clause entry for table