Rahul
Rahul

Reputation: 15

how to remove blank spaces in mysql table?

I want to remove those blank spaces and is there any way to add data in the same row if it is null instead of adding in the next row

Upvotes: 1

Views: 1160

Answers (3)

Ahmer Saeed
Ahmer Saeed

Reputation: 596

Make use of the following query according to your table name and column name in order to remove the blank entries in your database.

DELETE FROM "table name" WHERE "column name" IS NULL;

and make use of the following query in order to update the already existing row

UPDATE "table name" SET "column name" = "any thing" WHERE "condition";

Upvotes: 0

jai dutt
jai dutt

Reputation: 790

Hi you can use TRIM() function and replace() for /r/n

select replace(replace(trim(coloum_name),'/r',''),'/n','') from table;

and yes you can replace null with

select coalesce(coloum_with_null,'any_value') from table;

Upvotes: 1

Văn Tuấn Phạm
Văn Tuấn Phạm

Reputation: 659

You can use Trim() function.

Example 1

INSERT INTO table_name (column1,column2,column3,...)
VALUES (TRIM('  value1 '),TRIM(' value2 '),TRIM(' value3 '),...);

Result:

'value1'....

Upvotes: 0

Related Questions