Home > Software engineering >  how to delete a value from a column in SQL
how to delete a value from a column in SQL

Time:04-26

How can I delete only the field of a column without deleting the entire row? I have a table that owns the fields: ID, Name, Mail, Phone, Company and Would like to delete only the email of a person without deleting all the fields.

If I use:

DELETE FROM TEST_TABLE WHERE MAIL = '[email protected]' 

that way will delete everything and I want to delete just the email

CodePudding user response:

you can use this

Update myTable set MyColumn = NULL where Field = Condition.

References

1- How do I set a column value to NULL in SQL Server Management Studio?

2- UPDATE, DELETE, and INSERT Statements in SQL

CodePudding user response:

try

UPDATE
  TEST_TABLE 
SET
  MAIL = ''
WHERE
  id = your_id

or

if you want delete the field

ALTER TABLE TEST_TABLE 
DROP COLUMN MAIL;
  • Related