MySqlLIKE searches for records with Backslash ""

Source: Internet
Author: User
In mysql, like fuzzy queries do not support diagonal line queries, because in normal cases, the backslash in mysql is negotiable, next I will show you how to use MySqlLIKE to find records with Backlash. If you need it, please refer to it.

In mysql, like fuzzy queries do not support diagonal line queries, because in normal cases, the backslash in mysql is negotiable, next I will show you how to use MySql LIKE to find records with backslashes. If you need them, please refer to them.

Use or \ To see how you define the string. In fact, there are only two escape types: PHP and MySQL.

If you use double quotation marks "" to define a string in PHP, an escape occurs here. If you use single quotes, they will not be escaped.

$ SQL = "SELECT * FROM table WHERE col LIKE '% a \ %'";

In this way, what is actually escaped to MySQL?

SELECT * FROM table WHERE col LIKE '% a \ % ';

If you use single quotes, they will not be escaped (except single quotes, of course, the variables will not be expanded ):

$ SQL = 'select * FROM table WHERE col LIKE '% a \ % '';

Also sent to MySQL

SELECT * FROM table WHERE col LIKE '% a \ % ';

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.