SQLite : Trigger with multiple tables’ data

sqlite3 ji.db

create table first_table (a integer);
create table second_table (b integer);
create table new_table (c string);

create trigger anukul_sample after insert on first_table begin insert into new_table (c) values (‘first_table-‘ || new.a || ‘ second_table-‘ || (select b from second_table));end;

insert into second_table values (2);

select * from new_table;
insert into first_table values (1);
select * from new_table;

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s