Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
field Test type Varchar(100)

value on path "D:\\Test"


<pre>value on path "D:"


is just in character :


I solve like this
Drive varchar(1)
Path varchar(100)

d
Test


SELECT * FROM db_catalogo.tb_import
WHERE db_catalogo.tb_import.drive = 'D'
AND db_catalogo.tb_import.path = 'Test';


but to be able to use the full path (D:\Test) would be more comfortable


What I have tried:

Query with MySqlWorkBench

SELECT * FROM db_catalogo.tb_import
WHERE db_catalogo.tb_import.path LIKE 'd%';
ok , find record

SELECT * FROM db_catalogo.tb_import
WHERE db_catalogo.tb_import.path LIKE 'd:%';
no record found
Posted
Updated 12-Apr-21 4:11am

1 solution

The issue comes because \x is interpreted as an escape character. One way to avoid this is change the \ by / in all path. If You don't want to do that you can use \\ what means \ itself for each \ in the text You are looking for. For instance:

If You stored 'D:\Test' in the column db_catalogo_tb_import.path the the select command should be like:

SQL
select * from db_catalogo.tb_import where db_catalogo.tb_import.path='D:\\Test';


If You stored 'D:\\Test' then the select command should be like:

SQL
select * from db_catalogo.tb_import where db_catalogo.tb_import.path='D:\\\\Test';
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900