oracle11g - Oracle query to get the results of a particular table using the result obtained from another table -
i new oracle, kindly bear me if question sounds naive.
so, have 2 tables tablea , tableb have 2 columns id, name simplicity.
i want id value particular value of name in tablea. if requirement, query suffice -
select id tablea name = 'some_name'; now, want take id , delete rows in tableb match id-
delete tableb id = <id obtained above query>; what composite query in oracle perform function?
thanks!
if know single id value going returned particular name value, you'd do
delete tableb b b.id = (select a.id tablea a.name = 'some_name') note aliases optional. however, adding aliases makes things clearer no 1 has guess id or name you're referring @ point.
if there might multiple id values in tablea given name, you'd use in rather =
delete tableb b b.id in (select a.id tablea a.name = 'some_name') this work if knew query against tablea going return 1 row. i'd prefer equality query if you're sure 1 row returned, though. i'd rather error if expectations violated rather potentially having unexpected rows deleted.
Comments
Post a Comment