How to MYSQL UPDATE fieldINT!=‘4’ doesn’t work [closed]
-
11-09-2019 - |
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, priorityINT DESC, id ASC LIMIT 7;
Solution
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'
OTHER TIPS
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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow