Dave123 Dave123 - 2 months ago 6
Python Question

How to delete record from table where field is equal to header?

I have a sqlite table which contains duplicate headers which I would like to remove. This is my current statement.

DELETE FROM table WHERE FIELD = "FIELD"


This statement, when executed, deletes the entire table.

Answer

Don't use double quotes for strings!

delete from table where field = 'field';

The SQL standard for string delimiters is single quotes. Sometimes double quotes are used, but they are also used as escape characters for column names. So your code was just where field = field and that deletes all non-NULL values.

Comments