Subject Re: delete from table... best way?
Author Sergio
> 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.


Thanks for answer! Probably I wasn't clear enough... here's an example:

table "cars"
fields = id, car_name, id_driver

table "drivers"
fields = id, driver_name

table "cars" has a FK to table "drivers"
... foreign key (id_driver) references drivers(id)...

Now I want to delete all cars that *has* a record in "drivers", but the driver_name is null

so far, I always do

delete from cars
where
(
select drivers.driver_name
from drivers
where
cars.id_drivers = drivers.id
)
is null

that works fine, but I just wander if there is a better way... just for curiosity...

thanks!!

-s