Wednesday, January 26, 2011

Oracle escaping the % in like

Just figured out how to escape the % when using like in an Oracle SQL query e.g. if I want to get all rows from a table where the URL field contains "%20" which is the space in a URL.
select * from table_name where URL like '%!%20%' escape '!'

This indicates that '!' is the escape character and you would like to find all URLs that contain '%20'.