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

  • SEARCH
  • Home
  • 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 8202973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:22:55+00:00 2026-06-07T07:22:55+00:00

I have an application that has had a single table where all my data

  • 0

I have an application that has had a single table where all my data for this query was stored:

SELECT item, name, address, city, state, zip, latitude, longitude, expiration, photo, (((acos(sin((“.$submission->latitude.”*pi()/180)) * sin((latitude*pi()/180))+cos((“.$submission->latitude.”*pi()/180)) * cos((latitude*pi()/180)) * cos(((“.$submission->longitude.”- longitude)*pi()/180))))*180/pi())*60*1.1515*1.609344) as distance FROM Offers HAVING distance < 150 AND expiration > ‘$daytime – 6’ ORDER BY distance;

Basically the query finds the selected information, performs a calculation to find the distance from $submission->latitude/longitude and sorts by those distances.

Due to some outsourced development work, the select data is now spread out amongst 3 tables:
table business:
business_id, name, address, city, state, zip

table location:
business_id, location_id, latitude, longitude

table offers:
business_id, item, expiration, photo

I am having a heck of time getting a query to produce the same results on the split table structure. I have tried JOIN on business_id variations, but seem to get complaints about unknown columns and/or every derived table must have its own alias.

I am by no means a good MySQL query builder, hence I am asking for some pushes in the right direction on how I might approach this.

Thanks in advance.

  • 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-07T07:22:57+00:00Added an answer on June 7, 2026 at 7:22 am

    You have to simply join your queries

    $t1 = business table
    $t2 = location tabe
    $t3 = offers table
    
    SELECT $t1.*,
           $t2.location_id,($t2.latitude .. compute ),($t2.longitude ... compute),
           $t3.item, $t3.expiration, $t3.photo
    FROM $t1
    JOIN $t2 on $t1.business_id = $t2.business_id
    JOIN $t3 on $t3.business_id = $t1.business_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that has 2 beans with the same name, but which
We have an application that has a database full of polygons (currently stored as
The situation is this: a table that is used in a query (name it
I have a application that has an activity that shows message logs. The thing
I have an application that has two localization options at the moment through .resx
I have an application that has two threads. The first one (the main thread)
i have an application that has a dependancy on gdiplus. i need the application
I have an application that has a list of buttons and has customized tooltips.
I have an application that has a .sql file in it. The sql file
We have an application that has a WCF service (*.svc) running on IIS7 and

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.