MySQL Forums
Forum List  »  Newbie

Re: SQRT / Pythagoras Query problem
Posted by: gary campbell
Date: May 16, 2014 01:54PM

Thanks for your help Peter, I really appreciate it. I now have a working query thanks to you that returns all the right data, (it's probably ugly and cumbersome but it works):

SELECT b.T_Name as Attraction, a.A_Name as Hotel, a.A_Address as Address, a.A_Postcode as Postcode, a.A_Telno as Telno, SQRT(((b.T_X_coord - a.A_X_coord) * (b.T_X_coord - a.A_X_coord)) + ((b.T_Y_coord - a.A_Y_coord) * (b.T_Y_coord - a.A_Y_coord))) as Distance

FROM mydb.Accom a join mydb.Assign.Attract b
WHERE mydb.b.T_Name = 'FUN1'
ORDER BY Distance ASC

Two more things and I'll leave you all alone, promise ;)

The distances returned by the pythagoras function are 12.3456………… and I'd like to limit the digits 12.34 only, (I know it should be decimal(2,2) but I cant see where in the statement to put it), and
How do I limit the returns to only those distances less than 10?

Thanks

Options: ReplyQuote


Subject
Written By
Posted
Re: SQRT / Pythagoras Query problem
May 16, 2014 01:54PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.