#2014 - Commands out of sync; you can't run this command now

Jaxel

Well-known member
I am trying to run some MySQL code...
Code:
SELECT *,
    event_players - event_claimed AS event_unclaimed
FROM EWRtorneo_events
WHERE event_state = 'visible' AND league_id = 1
    ORDER BY event_date DESC, event_name DESC

#2014 - Commands out of sync; you can't run this command now

Now this error ONLY shows up when the search results contains a row where the column for event_players is equal to 0. What does this error mean?

If I remove either:
  • event_players - event_claimed AS event_unclaimed
  • ORDER BY event_date DESC, event_name DESC
Then the code starts working. However, both those lines are essential for my function.
 
I figured it out... if either of the variables in the subtraction statement in MySQL is an unsigned integer, then the result must always be an unsigned integer as well. If there is ever an instance where the result could be negative, the command will fail.

I solved this by casting the variables as signed:
Code:
SELECT *,
    CAST(event_players AS SIGNED) - CAST(event_claimed AS SIGNED) AS event_unclaimed
FROM EWRtorneo_events
WHERE event_state = 'visible' AND league_id = 1
    ORDER BY event_date DESC, event_name DESC
 
Top Bottom