Skip to content

Instantly share code, notes, and snippets.

View isaacerd's full-sized avatar

Isaac Ramirez isaacerd

View GitHub Profile
@ianldgs
ianldgs / cancel_delete.sql
Last active April 16, 2018 16:53
Cancel delete mysql
DELIMITER |
CREATE TRIGGER cancel_delete BEFORE DELETE ON table
FOR EACH ROW
BEGIN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'DELETE canceled';
END |
DELIMITER ;
SELECT id, nombre, (6371 * ACOS(
SIN(RADIANS(lat)) * SIN(RADIANS(4.6665578))
+ COS(RADIANS(lng - -74.0524521)) * COS(RADIANS(lat))
* COS(RADIANS(4.6665578))
)
) AS distance
FROM direcciones
HAVING distance < 1 /* 1 KM a la redonda */
ORDER BY distance ASC