c# - SQLite In Clause not working in trigger -


i have 2 tables table1 , table2. table1 have columns id,stringids , table2 columns id,data

there 2 tables in picture

i have created trigger delete rows based on table1. doesn't works if comma seperated stringids more one. works if stringids single value

create trigger tgtriggername after delete on table1 begin delete table2 id in (old.stringids); end 

gordon right, table structure really not want. if reason must way, query might accomplish want:

delete table2  id = old.stringids                   -- id matches   or old.stringids id + ',%'          -- or id @ beginning of list   or old.stringids '%,' + id          -- or id @ end of list   or old.stringids '%,' + id + ',%'   -- or id in middle of list 

but that's mess. don't it. instead remove stringids column table1, , add column table2 called table1id indicate table1 id table2 record belongs to. table2 this

id     table1id     data 1      1            data 2      1            data 3      2            data 4      2            data 5      2            data ... 

then trigger query can be:

delete table2 table1id = old.id 

even more clean skip trigger , foreign key contstraint cascading delete. have feeling that's lesson day.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -