1

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 = 'myemail@gmail.com' 

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

jarlh
  • 42,561
  • 8
  • 45
  • 63
FireWolfBR
  • 13
  • 6

3 Answers3

1

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

hani
  • 11
  • 1
0

try

UPDATE
  TEST_TABLE 
SET
  MAIL = ''
WHERE
  id = your_id

or

if you want delete the field

ALTER TABLE TEST_TABLE 
DROP COLUMN MAIL;
0

It is good practice to update the field with a NULL instead of leaving it blank, this indicates that there is a missing value and will later allow you to do queries where something is NOT NULL, which will give better results if it isn't returning bad data. Remember, garbage in, garbage out.

UPDATE TEST_TABLE SET MAIL = NULL WHERE MAIL = 'myemail@gmail.com'