Search code examples
mysqlurldecode

MySQL SELECT with URL Decode


Is there a way to perform a MySQL query and have one of the columns in the output directly urldecode, rather than have PHP do it.

For example this table 'contacts' would contain,

------------------------------------
|name      |email                  |
------------------------------------
|John Smith|johnsmith%40hotmail.com|
------------------------------------
SELECT * FROM `contacts`

Would output,

John Smith | johnsmith%40@hotmail.com

Is there something along the lines of,

SELECT name, urldecode(email) FROM `contacts`

To output,

John Smith | johnsmith@hotmail.com


Solution

  • I managed to use a seperate line of PHP code to urldecode the query response back from the SQL statement before it was passed to the json_encode which is used for the JQuery autocomplete.