English 中文(简体)
sqlite - 如何在插入语句中的字符串中排除分号 [封闭]
原标题:sqlite - how to escape semicolons in a string in an insert statement [closed]

问题解决了...

我意识到通常你想要使用某种抽象层, 而不是在像 iOS 和 Android (如果你重新写入电话应用程序) 这样的平台有工具时为 SQLite 为 SQLite 撰写您自己的插入语句 。

不幸的是,由于我拥有的工具以及所涉及的不同平台/系统的数量,我处于这样一种情况中,由于我拥有的工具和所涉及的不同平台/系统的数量,这实际上不是一个选择。

我的问题很简单, 但我似乎无法通过 Google 、 堆叠流等找到答案... 我只想用 Webkit s “ executeSql” 命令来做下个查询 :

INSERT INTO someTable VALUES (  some string  ,   some string with a semicolon; in it  );

问题是 - 除非我删除分号, 否则这失败了 。 (注意: 加倍的单引号是因为发送到 Webkit s 执行 Sql 命令的语句需要逃跑 。 也许这是问题的一部分吗? )

如果我把第二字段的分号从字符串里拿出来 语句就很好了...

如果我背着反弹逃过分号... 没运气!

斯克利特的文件似乎充其量是平庸的,我一直不知道我该如何摆脱那个分号...任何帮助都会非常感激。

最佳回答

这工作很好:

CREATE Table DummyTable(FirstCol VARCHAR(25), SecondCol VARCHAR(25));
INSERT INTO DummyTable VALUES ( This is a test ,  This is test two; OK? );
SELECT * FROM DummyTable;

-- output
FirstCol                  SecondCol
========================= ========================= 
This is a test            This is test two; OK?

问题似乎在于您 SQL 语句中的报价翻了一番。

问题回答

暂无回答




相关问题
what is wrong with this mysql code

$db_user="root"; $db_host="localhost"; $db_password="root"; $db_name = "fayer"; $conn = mysqli_connect($db_host,$db_user,$db_password,$db_name) or die ("couldn t connect to server"); // perform query ...

Users asking for denormalized database

I am in the early stages of developing a database-driven system and the largest part of the system revolves around an inheritance type of relationship. There is a parent entity with about 10 columns ...

Easiest way to deal with sample data in Java web apps?

I m writing a Java web app in my free time to learn more about development. I m using the Stripes framework and eventually intend to use hibernate and MySQL For the moment, whilst creating the pages ...

join across databases with nhibernate

I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error: An association from the table xxx refers to an unmapped class. If the ...

How can I know if such value exists in database? (ADO.NET)

For example, I have a table, and there is a column named Tags . I want to know if value programming exists in this column. How can I do this in ADO.NET? I did this: OleDbCommand cmd = new ...

Convert date to string upon saving a doctrine record

I m trying to migrate one of my PHP projects to Doctrine. I ve never used it before so there are a few things I don t understand. In my current code, I have a class similar to this: class ...

热门标签