SQL语句中存在英文的单引号、双引号问题

SQL语句中存在英文的单引号、双引号问题

场景:
1、需要将 【O’MALL侨城商业中心】插入到Sqlite数据库中

update datatable set name_1 = ‘O’‘MALL侨城商业中心’ // 将单个单引号替换为2个单引号
update datatable set name_1 = “O’MALL侨城商业中心” // 存在单引号的值用引号引起来

update datatable set name_1 = “O’'MALL侨城商业中心” // 将单个单引号替换为2个单引号,可执行成功,但不建议这样做,会导致数据库中的字段值出现两个引号

2、需要将【OMALL侨城"商业中心】插入到Sqlite数据库中

update datatable set name_1 = “OMALL侨城”“商业中心” // 将单个引号替换为2个引号,可执行成功,但不建议这样做,会导致数据库中的字段值出现两个引号

update datatable set name_1 = ‘OMALL侨城"商业中心’ // 存在引号的值用单引号引起来

3、当需要将【O’MALL侨城"商业中心】插入到Sqlite数据库中

update datatable set NAME3_1=‘O’‘MALL侨"城商业中心’ where OID=1 // 将单个单引号替换为2个单引号

真实场景运用如下:
update datatable set NAME1_1=‘O’‘MALL侨城商业中心’ where OID=1
update datatable set NAME2_1=‘OMALL侨"城商业中心’ where OID=1
update datatable set NAME3_1=‘O’‘MALL侨"城商业中心’ where OID=1
update datatable set NAME4_1=‘O"MALL侨’‘城商业中心’ where OID=1

猜你喜欢

转载自blog.csdn.net/qq_39116201/article/details/89396330
今日推荐