An SQL statement containing a semicolon causes an error

Several people have reported that a semicolon inside a quoted string may cause an SQL error.

My current setup is a SQLite 3 database, and I'm trying to paste, one of my new data fields contains some HTML code, and as part of this, I have html objects that end with a semicolon, for example - è

A simple example request that I am trying to make is as follows:

insert into my_table (some_field) values ('Hello; world');

And the errors I get:

1)

insert into my_table (some_field) values ('Hello
Error : unrecognized token: "'Hello"

2)

world')
Error : near "world": syntax error

, SQL, , Hello; world . , , , , SQLite, , SQL, .

, SQL- , -, ?

, :

DROP TABLE IF EXISTS djp;
CREATE Table djp ("mykey" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "name" VARCHAR(25));
INSERT INTO djp (name) VALUES ('This is test two; OK?');
SELECT * FROM djp;

, ( ), ...

INSERT INTO djp VALUES (1, 'This is test two; OK?');
+5
3

, sqlite3.exe engine , ( ). INSERT INTO Foo VALUES () INSERT INTO Foo (column) VALUES (), , , Navicat.

+2

, - SQLite, SQLite. Navicat (: 10.1.2). , SqlQuery.

, , / SQLite !

MesaSQLite, ( ).

, , . , .

, :

Mac SQLite editor

SQLite?

, SQLite!:)

+1

, SQLite, escape- SQL. :

SELECT * FROM MyTable WHERE RevenueChange LIKE '%0\%' ESCAPE '\'

LIKE , 30%, 140% .. , PHP ? PDO MYSQLI

PDO:

<?php

    $name = 'one';
    $value = 1;

    $stmt = $dbh->prepare("INSERT INTO REGISTRY (name, value) VALUES (?, ?)");
    $stmt->bindParam(1, $name);
    $stmt->bindParam(2, $value);

    $stmt->execute();

?>

.

0

All Articles