Hi I have 2 SQL statements
Statement 1:
SELECT id, name, version FROM mydb WHERE device IS NULL AND Activated=1 ORDER BY id ASC LIMIT 10
Statement 2:
UPDATE mydb SET device='$device' WHERE name IN ('$itemsArray')
I have been getting the $itemsArray
array from the first statement, but now I need to combine these statements, and I am not sure how to go about it and still keep it efficient.
When I have tried it myself I get 0 rows affected:
UPDATE mydb SET device='$device' WHERE Name IN (SELECT name FROM mydb WHERE device IS NULL AND Activated=1 ORDER BY id ASC LIMIT 10)
Edit: Removed quotes from subquery. Now I get this error: "This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'"
Using MySQL Version: 5.7.15