Re: Trigger HelpPlease
Posted by:
David Guy
Date: July 08, 2015 07:00AM
Hi Peter
Thank you for your reply, that does make sense.
However, please forgive me as I am getting on a bit now and am a newbie at MYSQL, but I tried to do as you suggested and got an error:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'if (new.squawk between 6160 and 6167 or new.squawk between 6171 and 6177) and ne' at line 4
I am sure that I am making a newbie mistake, but haven't got a clue
my code is:
CREATE TRIGGER airfields_insert
BEFORE INSERT
ON realtime
if (new.squawk between 6160 and 6167 or new.squawk between 6171 and 6177) and new.altitude <= 4000 then
insert into airfields (airplane_id,user_id,icao24,created_at,timestamp,altitude,flight_number,latitude,longitude,heading,squawk,horizontal_speed,vertical_speed,Interested) (new.airplane_id,new.user_id,new.icao24,new.created_at,new.timestamp,new.altitude,new.flight_number,new.latitude,new.longitude,new.heading,new.squawk,new.horizontal_speed,new.vertical_speed,new.Interested);
end if;
Thanks and Regards
Dave
www.donnyradar.co.uk