I have a large mysql table and I just noticed an issue when trying to query the database. It seems like the ENTER key was pressed when some columns were inserted. For example, I can perform the following search:
$query = mysql_query("SELECT * FROM table WHERE color= 'red'");
Now, I may have 20 rows where the color is red but less are showing. When I use phpmyadmin to edit the lines not showing in the search results, I notice the color column says red but has a line break so that the cursor is on a line underneath the word “red”. If I use the backspace key once to erase the line then save the row, it now appears in my query results.
My database is quite large, so I was wondering if there was any way to search the database where color has any “extra characters” on the end of the value, and remove those extra characters.
TRIM only removes spaces by default. The following will remove the linebreak:
Ref: MySQL Documentation