开发者

How to MYSQL UPDATE fieldINT!=‘4’ doesn’t work [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 9 years ago.

Improve this question

Im trying to UPDATE queueStatusINT WHERE statusINT is 8 and queueStatusINT is NOT equal to 2 and type is $type. But I keep getting an error:

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

Im using this SQL query to do the update:

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

I have also noticed that I can do a NOT equal to in a SELECT command…

SELECT nameTXT FROM $mysqlTable WHERE queueStatusINT!='2' ORDER BY queueStatusINT DESC, priorit开发者_高级运维yINT DESC, id ASC LIMIT 7;


You need to use AND to combine your criteria, not just commas.

For example

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


Change your UPDATE to:

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

I assume queueStatusINT is an Integer (as the name suggests) - you should leave out the '' as they symbolize a string/character.

Best wishes, Fabian

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜