As per my application requirement, while inserting data into my database table, sometime field value is added padded with spaces at its left-side and sometime at its right-side. Now, problem occurs when I try a search query to find out desired data against such specific field. MySQL shows no result against the query whereas I believe that desired data is available in the table. I assume that padded spaces with the values cause the problem. Actually, I am unable to change my application such behavior. It would be wonder if I get an idea to trim padded spaces from the field while my select queries!
To trim spaces from the value of its both sides, MySQL provides TRIM() function. You can use TRIM to fix spaces problem in your select queries. Take an example:
SELECT * FROM tbl_name WHERE TRIM(field_name) = 'searching value'