The stored procedure still works, but I only need entries withdist_calculated IS NOT NULL . When I use this condition in where clause, it shows an error #1054 - Unknown column 'dist_calculated' in 'where clause'. Witout where the sentence works well and returns NULL entries too:
entity_id dist_calculated
49 NULL
50 NULL
52 4460.615
51 4875.179
And I want to exclude NULL.
I tried WHERE dist_calculated IS NOT NULLand WHERE cpe.dist_calculated IS NOT NULLstill threw an error.
My stored procedure:
DELIMITER //
CREATE PROCEDURE get_close_childcares(IN latUser DECIMAL(15,6),IN lngUser DECIMAL(15,6) )
BEGIN
SELECT cpe.entity_id , get_distance_in_miles_between_geo_locations(latUser,lngUser,
(SELECT cpev.value FROM catalog_product_entity_varchar AS cpev
WHERE (cpev.entity_id = cpe.entity_id AND cpev.attribute_id = 176)
),
(SELECT cpev.value FROM catalog_product_entity_varchar AS cpev
WHERE (cpev.entity_id = cpe.entity_id AND cpev.attribute_id = 177)
)
) AS dist_calculated
FROM catalog_product_entity AS cpe
WHERE dist_calculated IS NOT NULL
ORDER BY dist_calculated ASC
LIMIT 0,4;
END
//
DELIMITER ;
And the call to the stored procedure:
call get_close_childcares(19.992100,73.777000)
Thank.
source
share