0

试图让以下工作,但对于我的生活,我无法让这个工作。

有人可以帮忙吗?

DELETE FROM 'content' WHERE note_id = '7' AND WHERE userid = '1'
DELETE FROM 'note' WHERE id = '7' AND WHERE userid = '1'

我需要从每个表中删除一条记录,在该表中检查用户实际上是那个用户,但是当我运行查询时出现语法错误

当我删除第二个 WHERE 时,我收到以下信息。

SQL 错误 (1064):您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,note在第 2 行的 'DELETE FROM WHERE id ='7' AND userid = '1"附近找到正确的语法给用户

抱歉,我在脚本到达这里之前添加了一个额外的空间

4

5 回答 5

8

WHERE需要1个,试试这个:

DELETE FROM content WHERE note_id = '7' AND userid = '1'
DELETE FROM note WHERE id = '7' AND userid = '1'
于 2012-09-06T12:11:22.107 回答
7

您不能在表名周围使用单引号:

DELETE FROM `content` WHERE note_id = '7' AND userid = '1'

您必须在表名和列名周围使用反引号 - 而不是单引号。

另外:你有两个where在那里 - 只是and在额外的子句之间使用。

于 2012-09-06T12:15:00.543 回答
3

WHERE在单个查询中添加了多个子句,这将不起作用。

试试这个:

DELETE FROM content WHERE note_id = '7' AND userid = '1'

DELETE FROM note WHERE id = '7' AND userid = '1'

于 2012-09-06T12:12:41.540 回答
1

采用

DELETE FROM 'content' WHERE note_id = '7' AND userid = '1'
DELETE FROM 'note' WHERE id = '7' AND userid = '1'
于 2012-09-06T12:15:16.063 回答
0
 DELETE FROM content WHERE note_id = '7' AND userid = '1'
 DELETE FROM note WHERE id = '7' AND userid = '1'

试试这个有两个错误,'表和where子句写了两次

于 2016-04-22T08:07:17.483 回答