Click here to Skip to main content
15,904,497 members
Home / Discussions / Database
   

Database

 
Questionjdbc Pin
Smart00315-Feb-13 20:24
professionalSmart00315-Feb-13 20:24 
AnswerRe: jdbc Pin
Richard MacCutchan15-Feb-13 22:31
mveRichard MacCutchan15-Feb-13 22:31 
AnswerRe: jdbc Pin
Mycroft Holmes16-Feb-13 15:21
professionalMycroft Holmes16-Feb-13 15:21 
QuestionOlder generation SQL syntax - Oracle Pin
vanikanc13-Feb-13 2:37
vanikanc13-Feb-13 2:37 
AnswerRe: Older generation SQL syntax - Oracle Pin
Jörgen Andersson13-Feb-13 10:30
professionalJörgen Andersson13-Feb-13 10:30 
GeneralRe: Older generation SQL syntax - Oracle Pin
vanikanc13-Feb-13 10:37
vanikanc13-Feb-13 10:37 
AnswerRe: Older generation SQL syntax - Oracle Pin
Shameel15-Feb-13 4:17
professionalShameel15-Feb-13 4:17 
QuestionHaving a bad SQL day Pin
TheComputerMan12-Feb-13 23:40
TheComputerMan12-Feb-13 23:40 
I am sure I am overlooking something very simple but I can't see it.

I have a database of locations with latitudes and longitudes. I need to be able to query for locations that fall within a given radius from a lat/lon point

The code I am intending to use is: (Showing fixed centre 38,-118 in this version)

SQL
SELECT quakeid, (6371 * acos(cos(radians(38)) * cos(radians(latitude)) * cos(radians(longitude) - radians(-118)) + sin(radians(38)) * sin(radians(latitude)))) AS [dkm] 
FROM tblUSGSData 


(Derived from Creating a store locator[^])

This works fine and returns just over half a million entries.

My problem is that as soon as I add

SQL
HAVING [dkm] <= 50


or

SQL
WHERE [dkm] <= 50


I get the message

Msg 207, Level 16, State 1, Line 3
Invalid column name 'dkm'.

I obviously have not got my SQL glasses on today as I can't seem to resolve this. Can any one make (polite) suggestions?
AnswerRe: Having a bad SQL day Pin
Jörgen Andersson13-Feb-13 0:20
professionalJörgen Andersson13-Feb-13 0:20 
GeneralRe: Having a bad SQL day Pin
TheComputerMan13-Feb-13 0:32
TheComputerMan13-Feb-13 0:32 
GeneralRe: Having a bad SQL day Pin
Jörgen Andersson13-Feb-13 0:40
professionalJörgen Andersson13-Feb-13 0:40 
GeneralRe: Having a bad SQL day Pin
Bernhard Hiller13-Feb-13 3:24
Bernhard Hiller13-Feb-13 3:24 
GeneralRe: Having a bad SQL day Pin
TheComputerMan13-Feb-13 3:33
TheComputerMan13-Feb-13 3:33 
AnswerRe: Having a bad SQL day Pin
Shameel13-Feb-13 0:53
professionalShameel13-Feb-13 0:53 
GeneralRe: Having a bad SQL day Pin
Jörgen Andersson13-Feb-13 0:56
professionalJörgen Andersson13-Feb-13 0:56 
GeneralRe: Having a bad SQL day Pin
PIEBALDconsult13-Feb-13 4:01
mvePIEBALDconsult13-Feb-13 4:01 
GeneralRe: Having a bad SQL day Pin
Jörgen Andersson13-Feb-13 6:27
professionalJörgen Andersson13-Feb-13 6:27 
QuestionWhat is Ado.net Pin
Himanshu Sharma 88812-Feb-13 19:20
Himanshu Sharma 88812-Feb-13 19:20 
AnswerRe: What is Ado.net Pin
Richard MacCutchan12-Feb-13 22:31
mveRichard MacCutchan12-Feb-13 22:31 
GeneralRe: What is Ado.net Pin
Shameel13-Feb-13 0:44
professionalShameel13-Feb-13 0:44 
GeneralRe: What is Ado.net Pin
Thomas Gabriel20-Feb-13 22:42
Thomas Gabriel20-Feb-13 22:42 
AnswerRe: What is Ado.net Pin
Sandeep Mewara13-Feb-13 0:23
mveSandeep Mewara13-Feb-13 0:23 
QuestionSQL 2008 Truncate vs Delete Pin
mrfalk12-Feb-13 6:47
mrfalk12-Feb-13 6:47 
AnswerRe: SQL 2008 Truncate vs Delete Pin
Eddy Vluggen12-Feb-13 7:48
professionalEddy Vluggen12-Feb-13 7:48 
GeneralRe: SQL 2008 Truncate vs Delete Pin
mrfalk12-Feb-13 8:27
mrfalk12-Feb-13 8:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.