如何在SQL中写RDBMS的特殊字符而不被执行其功能(how to escape sepecial characters in sql)

来源:互联网 发布:美工常用设计字体打包 编辑:程序博客网 时间:2024/06/05 08:29

2个方法:

1,用"/"转义:

INSERT INTO tab (field1)  VALUES('i/'m dreaming');

SELECT * FROM tab where field1='i/'m dreaming';

2,用2个单引号'':

INSERT INTO tab (field1) VALUES('i''m dreaming');

SELECT * FROM tab WHERE field1='i''m dreaming';