Wednesday, February 27, 2008, 08:50 AM - General
Posted by Administrator
With most special characters in languages and, in this case, SQL, there is a way to escape them (which means have the character count for what it really is instead of the special meaning).Posted by Administrator
In mySQL, if you want to search for the % character, which means match anything and normally returns the entire table if that is all that is in the where clause, you would need to do this:
SELECT * FROM yourtable WHERE troublecolumn='%\%%'
That means find any number of characters, then a literal % and then any number of characters. This allows the literal % to be at the front, in the middle, or at the end of the searched column.
This same principal can be applied to the other special characters, like # for example:
SELECT * FROM yourtable WHERE troublecolumn='%\#%'
Enjoy!




( 3 / 352 )

Calendar
