views:

29

answers:

2

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, priorityINT DESC, id ASC LIMIT 7;
+3  A: 

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'
martin clayton
Cheers, that works.
Mint
+1  A: 

Hi. 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

halfdan