Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8106619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:31:14+00:00 2026-06-06T00:31:14+00:00

I’ve got a rather lengthy query i have been working with that is throwing

  • 0

I’ve got a rather lengthy query i have been working with that is throwing the error ‘#1052 – Column ‘lat’ in field list is ambiguous’. I have broken it into parts and each part seems to work fine but when I run it at once I get this error. Here is the query:

    SELECT lesson_requests_global_2.student_name,
           (3959 * ACOS(COS(RADIANS(30.096595)) * COS(RADIANS(lat)) * COS(RADIANS(lng) - RADIANS(- 81.718983)) + SIN(RADIANS(30.096595)) * SIN(RADIANS(lat)))) AS distance,
           lesson_requests_vendor.user_purchased
    FROM lesson_requests_global_2
    INNER JOIN
      ( SELECT student_name,
               MAX(request_date) AS max_request_date
       FROM lesson_requests_global_2
       WHERE ( 3959 * ACOS(COS(RADIANS(30.096595)) * COS(RADIANS(lat)) * COS(RADIANS(lng) - RADIANS(- 81.718983)) + SIN(RADIANS(30.096595)) * SIN(RADIANS(lat))) ) < 30
       GROUP BY student_name ) AS recent_student_lesson_request ON lesson_requests_global_2.student_name = recent_student_lesson_request.student_name
    AND lesson_requests_global_2.request_date = recent_student_lesson_request.max_request_date
    LEFT JOIN lesson_requests_vendor ON v.user_purchased = lesson_requests_global_2.student_name
    WHERE lesson_requests_vendor.user_purchased <> 'bob jones'
      AND distance < 30
    ORDER BY distance LIMIT 0 , 20

Please note that the long COS/RADIANS stuff looks complicated but it is to find a mile radius distance. I think that somehow it is thinking ‘lat’ within those formulas is somehow in the column list?

Thanks in advance for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T00:31:16+00:00Added an answer on June 6, 2026 at 12:31 am

    Is very simple.

    You join on the same table from where you select, so you’ll have two column with the same name.
    If you don’t put the “table name” before your field name, this will produce a sql error.

    You can do something like this:

    SELECT .... FROM lesson_requests_global_2 request
    INNER JOIN
    ( SELECT ..... FROM lesson_request_globals_2 .....)
    ....
    WHERE ....
    

    and rename every occurrence of lat in request.lat

    request is now an alias from your table name: “virtually” the first you’re choosing from.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.