You are here
Home > Business > How to delete rows from another table in SQLITE?

How to delete rows from another table in SQLITE?

I have these tables

AT_WAR Primary key Ship_Name and War_ID

Ship_Name War_ID
First 1
Second 2
Third 3

SHIP Primary key Ship_Name

Ship_Name Ship_Type_ID
First S.1
Second S.2
Third S.3
FOURTH S.4

I want from the SHIP table to delete the ships that did not take part in a war. If i want to show the ships that participates in a war i can use this command:

SELECT DISTINCT SHIP.Ship_Name FROM SHIP
INNER JOIN AT_WAR ON SHIP.Ship_Name = AT_WAR.Ship_Name

I am using this command but did not work

DELETE FROM SHIP 
INNER JOIN AT_WAR ON SHIP.Ship_Name = AT_WAR.Ship_Name
WHERE AT_WAR.Ship_Name IS NULL;

Thank you in advance!

Top