[Solved] MySQL Syntax Error – Individual queries run successfully, but together they fail [closed]


You can combine these into a single query by joining with a subquery that sets the variable.

SELECT 
    CASE
        WHEN id % 2 == 0 THEN id - 1
        WHEN id = @maxid THEN id
        ELSE id + 1
    END AS id,
    student
FROM Seat
CROSS JOIN (SELECT @maxid := MAX(id) FROM Seat)
ORDER BY id

0

solved MySQL Syntax Error – Individual queries run successfully, but together they fail [closed]