- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
In what cases, we cannot use MySQL TRIM() function?
152 Lectures 16 hours
87 Lectures 5.5 hours
Actually for using MySQL TRIM() function we must have to know the string which we want to trim from the original string. This becomes the major drawback of TRIM() in the cases where we want to trim the strings having different values. For example, suppose we want to get the output after trimming the last two characters from the strings but every string is having different characters at last two places.
mysql> Select * from Employee; +------+----------------+------------+-----------------+ | Id | Name | Address | Department | +------+----------------+------------+-----------------+ | 100 | Raman | Delhi | IT | | 101 | Mohan | Haryana | History | | 102 | Shyam | Chandigarh | ENGLISH | | 103 | Sukhjeet Singh | Patiala | Computer Engg. | | 104 | Bimal Roy | Calcutta | Computer Engg. | +------+----------------+------------+-----------------+ 5 rows in set (0.00 sec)
As in the above table suppose I want to get the output after trimming the last two characters from Name, Address and Department Column then to get the desired output with one query by using TRIM() is not possible because the values at last two characters are not same.
Another case, when we cannot use TRIM() function, is When we want to remove the unwanted characters in the middle of the string. It is because TRIM() function only removes the unwanted leading or trailing characters from a string. For example, in the above table we cannot remove space between ‘Sukhjeet Singh’ by using TRIM() function.
- What is the purpose of MySQL TRIM() function?
- Why we cannot use MySQL DATE data type along with time value?
- trim() function in PHP
- Data Types we cannot use to create array in C
- How can we use MySQL SUM() function?
- Use TRIM on all records in a MySQL table?
- What MySQL returns if we use UNIX_TIMESTAMP() function with no argument?
- How can we use MySQL TRIM() to remove the whitespaces from all the rows and update table?
- Will “create table table” work in MySQL since we cannot use reserved words as table name?
- How to use trim () in Android sqlite?
- How to use trim () in Android textview?
- How can we use MySQL INSTR() function with WHERE clause?
- How can we use MySQL SUM() function with HAVING clause?
- How can we use ASCII() function with MySQL WHERE clause?
- How can we use CHAR_LENGTH() function with MySQL WHERE clause?