Subject Re: [firebird-support] delete from table... best way?
Author Daniel L. Miller
On 9/15/2011 6:24 AM, Sergio H. Gonzalez wrote:
> [FB 2.5]
>
> Hello there!
>
> a have a very common situation... a table (T1) which is joined to T2...
> I want to delete all records from T1 that has a null description in T2
>
> this works fine:
>
> delete from t1 where (select t2.descripcion from t2 where (t1.id_t2 =
> t2.id)) is null
>
> but I wander if there is a better (shorter?) way to do the same...
>
Not sure what your use is - but if you have t1.id_t2 defined as a
foreign key with cascading deletes, then you can never have a t2.id null
and any delete of t1 will cascade and automatically delete the
associated records in t2.
--
Daniel