D
D
Denis Kuznetsov2020-04-15 21:36:22
PostgreSQL
Denis Kuznetsov, 2020-04-15 21:36:22

How to remove related entities in one request?

Hello, I tried to delete a row from the patr table and a row with a reference key referring to it
here are the table structures

Create table part(
  p_no integer primary key,
  p_name varchar(20) not null,
  price integer not null,
  color varchar(1) not null,
  weight integer not null
  );
 create table cells(
  sno integer not null,
  pno integer not null,
  foreign key(sno) references supplier(sno),
  foreign key(pno) references part(p_no)
  );


and the query that didn't work
delete  cells as c, part as p from с, p where c.pno = (
select p.p_no from p where p.p_name = 'Bearing') and p.p_name = 'Bearing';


Please explain why the request did not work and what needs to be fixed in it, thanks in advance

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question