mysql - Trigger to delete blank rows after INSERT -


i have inserted set of data database, want delete rows blank values. how can this? can done using triggers?

example:

table books contains author_name, title, price.

after inserting data, want delete rows empty values in author_name column. here's i've written far:

create trigger trigger1   after insert   on  books   each row    begin   delete books author_name = ''   end; 

this not working :(

the issue you've got begin…end around statement not delimited ;. if put missing ;, however, need introduce meta delimiter entire definition, because, if don't that, inner ; break it.

so, put ; @ end of delete statement , introduce delimiter before trigger definition:

delimiter $$ create trigger trigger1   after insert   on  books   each row  begin   delete books author_name = ''; end $$ 

alternatively, since body contains 1 statement, can remove begin…end:

create trigger trigger1   after insert   on  books   each row  delete books author_name = ''; 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -