In my database table, 16 rows are inserted with null values for all columns. How can I delete these rows using SQL statement?

Recommended Answers

All 2 Replies

Something like this:

DELETE FROM my_table WHERE col1 IS NULL AND col2 IS NULL AND col3 IS NULL AND col4 IS NULL

To stop it from happening in the future, consider adding a primary key to the table. By definition a PK is not nullable and will help identify the records when they are inserted. For more information on primary keys see this W3Schools page on the subject.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.