TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 10-07-2010, 07:24 PM   #1 (permalink)
The Visitor
Newcomer 
 
Join Date: Oct 2010
Location: Pompano Beach, FL
Posts: 1
Thanks: 0
oceanrockn is on a distinguished road
Default Join Tables with Distance Calculation

I am trying to join two tables together. First is a calendar of events with lat/lng sorted by distance. I also need to get the business information from the directory table.

This one works without joining the tables without the JOIN:

PHP Code:
$query "SELECT calendar.id,calendar.coupon,( 3959 * acos( cos( radians($lat) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( lat ) ) ) ) AS distance FROM calendar HAVING distance < $miles"
This is the code that does not work, have tried many variations:

PHP Code:
$query "SELECT calendar.id,calendar.coupon,directory.business,( 3959 * acos( cos( radians($lat) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( lat ) ) ) ) AS distance FROM calendar RIGHT JOIN directory ON calendar.id = directory.id HAVING distance < $miles"
If anyone can help it would be much appreciated
oceanrockn is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
What is good MySQL practice? Aaron MySQL & Databases 7 11-23-2012 10:56 AM
Google Maps API to calculate distance between zips? jcorradino General 2 10-30-2008 01:37 PM
php join tables tego10122 General 6 10-06-2008 10:27 PM
Tables joining other Tables? Orc MySQL & Databases 6 02-09-2008 09:42 PM
Get data from 4 different tables Ultimatum MySQL & Databases 7 01-16-2008 12:34 PM


All times are GMT. The time now is 06:25 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design