Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用特殊字符正斜杠'\';或反斜杠'/';在MySQL中_Mysql_Sql_Special Characters_Sql Like - Fatal编程技术网

使用特殊字符正斜杠'\';或反斜杠'/';在MySQL中

使用特殊字符正斜杠'\';或反斜杠'/';在MySQL中,mysql,sql,special-characters,sql-like,Mysql,Sql,Special Characters,Sql Like,我将文件的完整路径详细信息存储在一个表中,并为其指定名称和Id。 现在检索下面查询中的行 select * from path_table where path = 'D:\\\WorkBench\\\Demo\\\sample.txt' 这很好用 如何在MySQL中使用“like”获得相同的结果 select * from path_table where path like 'D:\\\WorkBench\\Demo\\\sample.txt' 此

我将文件的完整路径详细信息存储在一个表中,并为其指定名称和Id。 现在检索下面查询中的行

select *
     from path_table
     where path = 'D:\\\WorkBench\\\Demo\\\sample.txt'
这很好用

如何在MySQL中使用“like”获得相同的结果

select *
     from path_table
     where path like 'D:\\\WorkBench\\Demo\\\sample.txt'
此语句返回0行。 事实上我需要一些东西,比如如果我给

select *
     from path_table
     where path like 'D:\\\WorkBench\\\Demo\\\'
它应该返回所有行,即相同路径下的文件,因此需要将like与“%”一起使用。但它不起作用。我应该用什么来代替

你试过这个吗

select * from path_table where path like 'D:\WorkBench\Demo\%'
代替

select * from path_table where path like 'D:\WorkBench\\Demo\\%'
此外,请首先尝试使用完整路径,如下所示:

select * from path_table where path like 'D:\\WorkBench\\Demo\\sample.txt'
请尝试以下查询:

select * from path_table where path like '%D:\\WorkBench\\Demo\\%'
你忘了在开头和结尾加上这个符号(%)

注意:我把%符号放在开头也是因为数据库中可能添加了一些字符