Tags
PHP , MySQL
Asked 8 years ago
21 Nov 2016
Views 1496
sqltreat

sqltreat posted

how to remove whitespace in MySql in Sql Query ?

how to remove whitespace in MySql In Sql Query .
i am running following query with mysql_query in php


INSERT INTO `job_category` (`category`) VALUES ( ".$_REQUEST['category_name']."'),


but sometime i got admin enter category name with space. so i want to omit it to get stored name with space in MySql
can i remove white space before get it saved. ?
php function or MySql function any thing which help on this .
Mitul Dabhi

Mitul Dabhi
answered Nov 30 '-1 00:00

you can use TRIM function from MySql String function .

mysql_query("INSERT INTO `job_category` (`category`) VALUES (TRIM( '".$_REQUEST['category_name']."'))");

TRIM function will remove white space.

Post Answer