Mysql的WHERE子句中的文件名什么都不返回 [英] File Name in the WHERE clause of Mysql returns nothing
问题描述
我有这个 SELECT 查询,它从指定的表中不返回任何内容,但文件的路径存储在该表中;
I have the this SELECT query that returns nothing from the specified table yet the path to the file is stored in that table;
SELECT * from tableName WHERE imageFile = "C:\Documents and Settings\Albert Bayita\Desktop\MovieImages\TheLordOfTheRingsTheFellowship.jpg";
SELECT * from tableName WHERE imageFile = "C:\Documents and Settings\Albert Bayita\Desktop\MovieImages\TheLordOfTheRingsTheFellowship.jpg";
感谢任何建议.
推荐答案
反斜杠字符是 MySQL 中字符串中的转义字符.要在查询中的字符串文字中放置反斜杠,您必须使用双反斜杠对其进行转义.同样,SQL 中的字符串使用撇号作为分隔符,而不是引号.
The backslash character is the escape character in strings in MySQL. To put a backslash in a string literal in a query you have to escape it using double backslashes. Also a string in SQL uses apostrophes as delimiter, not quotation marks.
SELECT * from tableName WHERE imageFile = 'C:\\Documents and Settings\\Albert Bayita\\Desktop\\MovieImages\\TheLordOfTheRingsTheFellowship.jpg';
最好的选择当然是使用参数化查询.
The best option is of course to use a parameterised query instead.
这篇关于Mysql的WHERE子句中的文件名什么都不返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!