Database/MySQL
MySQL 이스케이핑 방법
2mukee
2023. 8. 13. 00:22
320x100
320x100
QUOTE()
: 문자에 대해 이스케이핑을 수행
: ' 이나 " 과 같은 quote 문자, \ / 등의 문제에 대해 이스케이핑 한채로 값을 반환함
: 그냥 SELECT로 선택하면 이스케이핑이 되지 않은채로 값이 나온다
mysql> SELECT QUOTE('w3re''source');
+-----------------------+
| QUOTE('w3re''source') |
+-----------------------+
| 'w3re\'source' |
+-----------------------+
1 row in set (0.03 sec)
다른 방법
- ESCAPE()
SELECT * FROM `titles` WHERE title LIKE 'test\\' ESCAPE '|'
Reference
MySQL QUOTE() function - w3resource
MySQL QUOTE() produces a string which is a properly escaped data value in an SQL statement, out of an user supplied string as argument.
www.w3resource.com
How can I search for slash (\) in MySQL? And why is escaping (\) not required for where (=), but for Like it is required?
Consider this QUERY (DEMO IS HERE) (SELECT * FROM `titles` where title = 'test\\') UNION ALL (SELECT * FROM `titles` where title LIKE 'test\\\\') Output: | ID | TITLE | -------------- | 1 | tes...
stackoverflow.com
300x250
728x90