Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Query needed: I need to delete all data from a single column

Tags:

mysql

I have an ecommerce store that I am currently working on and there are approx 300 products which have a field named "product_url"

These fields contains an old url that I need to delete altogether.

How can I create a query that will replace all "product_url" fields with data in them witha null value?

like image 606
Andy Smith Avatar asked Feb 10 '11 14:02

Andy Smith


People also ask

How can I delete one column data from a table in MySQL?

Syntax. The syntax to drop a column in a table in MySQL (using the ALTER TABLE statement) is: ALTER TABLE table_name DROP COLUMN column_name; table_name.

How do I delete all data in MySQL?

Deleting a MySQL or MariaDB database First list all databases on your server. Use the command 'SHOW DATABASES;' in the mysql-console like in the example above. Now copy the name of the database you want to delete. To do delete a database you need the command 'DROP DATABASE'.

Which of the following query is used if you want to delete a record from any MySQL table?

The MySQL DELETE Statement The DELETE statement is used to delete existing records in a table.


1 Answers

This will set every product_url to NULL which is currently not null.

UPDATE table_name
SET product_url = NULL
WHERE product_url is not null;
like image 144
FrustratedWithFormsDesigner Avatar answered Oct 01 '22 08:10

FrustratedWithFormsDesigner