database - Oracle SQL query a table and delete from an other based on the results -


so have following tables,

   create table accounts (         acc_id integer primary key,         acc_name varchar(50) not null     );      create table city (         zip varchar(20) primary key,         cityname varchar(30) not null     );      create  table address (         addr_id integer primary key,         street varchar(50) not null,         houseno varchar(10) not null,         zip varchar(20) not null references city on delete cascade     );       create table located (             acc_id integer not null references accounts on delete cascade,         addr_id integer not null references address on delete cascade,         primary key(acc_id, addr_id) 

i use similar query below able delete row based on result select query.

delete address add_id=(select addr_id located acc_id=1); 

is possible ? if yes how ?

you got it, proposal works in cases (when subquery finds 1 row). here more general case, need in instead of =:

delete address    add_id in (select addr_id located acc_id=1); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -