-2

我试图更新 queueStatusINT WHERE statusINT 为 8 且 queueStatusINT 不等于 2 且类型为 $type。但我不断收到错误消息:

ERROR 1064 (42000) at line 1: 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 ‘ queueStatusINT!='2’, type=’int'' at line 1

我使用此 SQL 查询进行更新:

UPDATE $mysqlTable SET queueStatusINT='2’ WHERE statusINT='8’, queueStatusINT!='2’, type=‘$type’;

我还注意到我可以在 SELECT 命令中执行 NOT 等于...</p>

SELECT nameTXT FROM $mysqlTable WHERE queueStatusINT!='2' ORDER BY queueStatusINT DESC, priorityINT DESC, id ASC LIMIT 7;
4

2 回答 2

3

您需要使用 AND 来组合您的条件,而不仅仅是逗号。

例如

UPDATE $mysqlTable 
SET    queueStatusINT = '2'
WHERE  statusINT      =  '8'
AND    queueStatusINT != '2'
AND    type           =  '$type'
于 2009-12-03T00:12:40.633 回答
1

将您的更新更改为:

UPDATE $mysqlTable 
SET queueStatusINT='2’ 
WHERE statusINT=8
AND queueStatusINT !=2 
AND type=‘$type’;

我假设 queueStatusINT 是一个整数(顾名思义) - 你应该省略 '' 因为它们象征着一个字符串/字符。

最好的祝愿,法比安

于 2009-12-03T00:15:36.870 回答