Skip to content

Instantly share code, notes, and snippets.

@olivermt
Created March 7, 2017 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olivermt/7d9fefd884cddfe919718fe7da82ee41 to your computer and use it in GitHub Desktop.
Save olivermt/7d9fefd884cddfe919718fe7da82ee41 to your computer and use it in GitHub Desktop.
[42P01] ERROR: invalid reference to FROM-clause entry for table "locations" Hint: Perhaps you meant to reference the table alias "location".
select
operations.legal_name as legal_name,
operations.operation_name as organization_name,
operations.general_description as general_description,
operations.is_exempt as is_exempt,
operations.does_export,
operations.phone,
operations.url,
operations.year_started,
operations.employees,
operations.contact_2_name,
operations.contact_2_phone,
operations.overseer_name,
operations.non_organic_production_description,
location.name,
location.address_text,
location.address,
location.city,
location.state,
location.postal,
location.country,
location.data,
billing_location.name,
billing_location.address_text,
billing_location.address,
billing_location.city,
billing_location.state,
billing_location.postal,
billing_location.country,
billing_location.data,
legal_location.name,
legal_location.address_text,
legal_location.address,
legal_location.city,
legal_location.state,
legal_location.postal,
legal_location.country,
legal_location.data,
users.id as user_id
from operations
LEFT JOIN users ON users.id = operations.user
LEFT JOIN locations as location ON operations.location = locations.id
LEFT JOIN locations as billing_location ON operations.billing_location = locations.id
LEFT JOIN locations as legal_location ON operations.legal_location = locations.id
WHERE operations.aca = 10110
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment