3
I am trying to perform a query in a table similar to the one below through a field diretorio.
+----------+---------------+----------------------------------------+
|id_imagem |  data_upload  |               diretorio                |
+----------+---------------+----------------------------------------+
|   1      | 2019-05-18    |   \\xxx.xxx.xxx.xx\xyzdnas\img1.png    |
|   2      | 2019-05-18    |   \\xxx.xxx.xxx.xx\dasdadg\img2.png    |
|   3      | 2019-05-18    |   \\xxx.xxx.xxx.xx\gnwwefi\img3.png    |
|   4      | 2019-05-18    |   \\xxx.xxx.xxx.xx\gdfgthh\img4.png    |
|   5      | 2019-05-18    |   \\xxx.xxx.xxx.xx\njfsdfu\img5.png    |
+----------+---------------+----------------------------------------+
The column I use for condition is the diretorio, however, I only have the IP address and the folder the files are in, and I need to get all the images that are in that folder from the BD.
I was initially trying to search:
SELECT * FROM db.tb WHERE diretorio LIKE '%\\xxx.xxx.xxx.xx\njfsdfu%';
However, the search does not return the values correctly, I did some searches in Google and found searches like these below but also failed:
SELECT * FROM db.tb WHERE diretorio LIKE '%\%\%xxx.xxx.xxx.xx\%njfsdfu%' ESCAPE '|';
SELECT * FROM db.tb WHERE diretorio LIKE '%\\\\xxx.xxx.xxx.xx\\njfsdfu%' ESCAPE '|';
but I could not get a result.
Does anyone know how to do this search?
PS: I’m using the MySQL and the column field diretorio is VARCHAR(600)
Since the character is an escape character then just duplicate ( ) to represent a single .
– anonimo