Search the Community
Showing results for tags 'triggers'.
Found 2 results
I’m trying to create a trigger that does two things, first take an ip that’s in dot notation and run inet_aton on it and put the result in another field. Second, checks a lookup table to identify an ip range that the result of the first action falls into and enters the id of that row in the table. This is on a mysql database on my web host. Here’s what I’ve tried: DELIMITER // CREATE TRIGGER before_ins_download BEFORE INSERT ON download FOR EACH ROW begin set new.ip_address = inet_aton(new.`ADDRESS`), new.refer=(select `id` from `ip_lookup` as i where new.ip_address between i.start and i.end limit 1 ); END; // DELIMITER ; It works without the new.refer part but after I added that it just seems to hang and never gets to the closing DELIMITER; . All ip columns are indexed. Does anyone see a mistake in my code? Thanks for looking.
I have set up a Trigger... update a_players p join wp_terms t set p.wpID = t.term_id where t.slug = p.wpSlug ...and it works. These are relatively new data tables, and I had intended on the trigger to just deal with new entries (as Tags posted via WordPress). However, it ended up updating previously applicable rows, which didn't anticipate. It makes sense, but before I go live, I'm going create term_id / wpID matches for all previous rows. As of now, wp_terms is just 42 rows, but it will grow a great deal once the site actually goes live. a_players currently has 150 rows but it going to approach about 1,000 rows before I go live, growing around 250 rows per year. Should I narrow my trigger down? If I should narrow it down to just deal with new entries, what do I need to add? If It's going to check every row in both tables, will that bog down my site? Thank you.