MySQL FAQs
FAQs Categories
Client Server Commands
Database Structure
Table Types or Storage Engines
Indexes
SQL Statements
Table Joins
Funtions and Operators
Tricky Select Queries
Speed Up Queries
Data Back Up
General Questions
Errors
N.M.P.L. Company www.NearMePayday.Loan || 3-month (90 days)
Powered by MySQL
 
Home / General Questions / Question No: 157

Why values with spaces do not come into search result?

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!

Answer No: 157

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'

Related MySQL FAQs to the Above FAQ

How-can-I-detect-that-MySQL-is-already-installed How can I detect that MySQL is already installed?

What-is-prepared-statement-in-MySQL What is prepared statement in MySQL?

Maximum-number-of-columns-in-a-table Maximum number of columns in a table

Can-I-use-FIELD-CONSTRAINTS-on-MySQL Can I use FIELD CONSTRAINTS on MySQL?

What-are-reserved-words-in-MySQL What are reserved words in MySQL?

How-to-manage-Time-Zone-in-MySQL How to manage Time Zone in MySQL?

What-is-History-of-MySQL What is History of MySQL?

How-does-MySQL-manage-case-sensitivity-of-identifiers How does MySQL manage case sensitivity of identifiers?

What-are-MySQL-connectors-or-client-interfaces What are MySQL connectors or client interfaces?

About FAQs: Recently Added FAQs

About MySQL FAQs: Site Map | Bookmark Us | Recommend this Site to Your Friend | Contact Us

Useful Links: Wikipedia.org | Oracle.com | w3schools.com | www.php.net | Github.com

© 2021  www.mysqlfaqs.net
All rights reserved.