1
다음 코드가 있습니다. 것은 SELECT LAST_INSERT_ID()와 함께 항상 마지막으로 삽입 된 행을 반환합니다. 내가 행이 실제로 마지막 행을 얻기 전에 삽입 또는 내가 간단한 다시 더 행이 INSERT IGNORE
삽입되지 않은 경우, Documentation를 참조 0INSERT IGNORE IN SELECT LAST_INSERT_ID()
SET _inserted_geolocation_id =(SELECT id FROM geolocation where latitude= _geolocation_latitude AND longitude = _geolocation_longitude
AND zoom = _geolocation_zoom AND yaw = _geolocation_yaw AND pitch =_geolocation_pitch);
BEGIN
DECLARE _inserted_geolocation_id int;
INSERT IGNORE INTO geolocation (latitude, longitude, zoom, yaw, pitch)
VALUES (_geolocation_latitude, _geolocation_longitude, _geolocation_zoom, _geolocation_yaw, _geolocation_pitch);
/*SET _inserted_geolocation_id = (SELECT LAST_INSERT_ID());*/
SET _inserted_geolocation_id =(SELECT id FROM geolocation where latitude= _geolocation_latitude AND longitude = _geolocation_longitude
AND zoom = _geolocation_zoom AND yaw = _geolocation_yaw AND pitch =_geolocation_pitch);
SELECT _inserted_geolocation_id;
END
SET_inserted_geolocation_id = (SELECT LAST_INSERT_ID()); 중복 행을 추가 할 때 마지막 행을 반환했습니다. –
geolocation (위도, 경도, 확대/축소, 요우, 피치)에 무시 함 VALUES (_geolocation_latitude, _geolocation_longitude, _geolocation_zoom, _geolocation_yaw, _geolocation_pitch); SELECT LAST_INSERT_ID(); –