Hi! please how do I completely remove a row from a sql table.
in the mission, the world data is included in the table so for each computation I have to write WHERE name != “World” to get accurate values. but sometimes I forget.
is there a way to drop the row completely?
You can delete that row from the database, but then it will be gone. You won’t be able to access it again (at least not in a easy and natural way) from within the database.
I suggest an alternative instead, which is to create a view. You can think of a view as a saved query.
By running the code below, you’ll create a view which you can access just like querying the
CREATE VIEW facts_wo_world AS
WHERE name <> 'World';
To query the view instead of
facts, you replace
If you really want to drop the row from
facts, you can run the following.
DELETE FROM facts
WHERE name = 'World';