我想在mysql中比较两个表,一切正常,直到我的python脚本想要检索" name" time"
错误信息类似于:
pymysql.err.ProgrammingError: (1064, u'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \ald"time" AND something = "Donald"time" UNION SELECT id FROM table1 WHERE something' at line 1')
我的mysql语句如下:
SELECT id FROM table1 WHERE something = "Donald"time"
我知道我可以忽略"有许多技巧,但遗憾的是我不知道引号位置只是插入一个转义序列。
由于
答案 0 :(得分:1)
与\
转义一样:
create table a
( id int auto_increment primary key,
b varchar(100) not null
);
insert a(b) values ('aabbcc'),('fish\"tonite');
SELECT id FROM a WHERE b = "fish\"tonite";
+----+
| id |
+----+
| 2 |
+----+
Mysql手册页Here,其中包含有关某些转义序列的信息。