-1

原来的查询是:

UPDATE `test`.`documents` SET `title` = ‘测试中文’, `content` = ‘this is my test document number two,应该搜的到吧’ WHERE `documents`.`id` = 2;

结果是:

#1064 - 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 'my test document number two,应该æ

我改错了'

UPDATE 'test'.'documents' SET 'title' = '测试中文', 'content' = 'this is my test document number two,应该搜的到吧' WHERE 'documents'.'id' = 2;

并得到:

#1064 - 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 ''test'.'documents' SET 'title' = '测试中文', 'content' = 'this is my test do' at line 1

如何设置我的 my.ini?

我使用了 XAMPP Lite 和 MySQL 版本 5.1.37。

4

5 回答 5

2

您使用的是 ', 而不是 ', (即奇怪的引号)

对于您的新问题,如果要引用表或列名,则需要使用 `s(反引号)而不是 '(反引号)。

于 2010-02-04T03:20:39.630 回答
1
于 2010-02-04T03:32:15.673 回答
0

在不确切知道您在何处以及如何使用该 SQL 语句的情况下,我只能猜测这可能是一个编码问题。尝试将编码更改为 UTF-8。

于 2010-02-04T03:23:25.867 回答
0

all mysql table and field names should be escaped with backticks: ` all mysql strings should should be enclosed with single quote: ' try this:

UPDATE `test`.`documents` SET `title` = '测试中文', `content` = 'this is my test document number two,应该搜的到吧' WHERE `documents`.`id` = 2;

to address #3: you need to alter the default charset for that table: "ALTER TABLEtest.documents. CONVERT TO CHARACTER SET utf8;" Be careful though, this may change the storage size requirements of the table, so if it's a large table, plan for the query to take a bit to execute.

to address #4: you should add the following to the [mysqld] section of my.ini:

collation_server=utf8_unicode_ci
character_set_server=utf8
于 2010-02-04T03:36:40.000 回答
0
UPDATE test.documents
SET title = '测试中文',
content = 'this is my test document number two,应该搜的到吧'
WHERE documents.id = 2; 

is also ok,and the same question is also my 3

于 2010-02-04T03:56:00.670 回答