SELECT From MySQL View With HAVING Clause Returns Empty Result Set

前端 未结 2 1525
孤城傲影
孤城傲影 2021-01-19 15:38

My business partner and I are having issues selecting from a MySQL view that has a HAVING clause.

The query simply selects a few fields from the view, determines a

2条回答
  •  孤独总比滥情好
    2021-01-19 16:32

    Try this:

    select * from (
        SELECT 
        restaurantName, 
        restaurantID, 
        locationID, 
        locationCity, 
        locationState, 
        locationAddress, 
        locationLatitude, 
        locationLongitude,
        ( 3959 * acos( cos( radians('%s') ) * cos( radians( locationLatitude ) ) * cos( radians( locationLongitude ) - radians('%s') ) + sin( radians('%s') ) * sin( radians( locationLatitude ) ) ) ) AS distance 
        FROM newView
    ) S
    where distance < '%s' 
    ORDER BY distance
    

提交回复
热议问题