Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 2 table query

Author  Topic 

pc_mac
Starting Member

2 Posts

Posted - 2013-08-08 : 05:23:24
Hi all

I was wondering if someone can help me with my query.

This is my query that works great:
 $query = sprintf("SELECT primary_key, address, postcode, lat, lng, ( 3959 * acos( cos( radians('%s') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians('%s') ) + sin( radians('%s') ) * sin( radians( lat ) ) ) ) AS distance FROM stores HAVING distance < '%s' ORDER BY distance LIMIT 0 , 5" 

I also need to retrieve data from a table called products; the primary key, col1 and col2.
The primary key being the common field.

How would I add to this query?
Hope someone can help me?

Many thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-08-08 : 06:15:08
Your code looks as if you're on MySQL. This is MS SQL Server forum and we deal only with transact sql. As there's not much expertise on MySQL here, you may try your luck at MySQL forums like www.dbforums.com where you'll have better chance of getting correct solution.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

pc_mac
Starting Member

2 Posts

Posted - 2013-08-08 : 11:23:11
Sorry about that!

Thank you!

quote:
Originally posted by visakh16

Your code looks as if you're on MySQL. This is MS SQL Server forum and we deal only with transact sql. As there's not much expertise on MySQL here, you may try your luck at MySQL forums like www.dbforums.com where you'll have better chance of getting correct solution.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs


Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-08-09 : 05:49:20
you're welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -