sql-parser icon indicating copy to clipboard operation
sql-parser copied to clipboard

LIMIT SYNTAX error when using SELECT FOR UPDATE

Open williamdes opened this issue 6 years ago • 4 comments

Execute

START TRANSACTION;
SELECT * FROM mytable WHERE id = 88777 FOR UPDATE;
# 1064 - Erreur de syntaxe près de 'LIMIT 0, 25' à la ligne 1
# 1064 - Syntax error near 'LIMIT 0, 25' at line 1

williamdes avatar Nov 06 '19 14:11 williamdes

        return Query::replaceClause(
            $analyzed_sql_results['statement'],
            $analyzed_sql_results['parser']->list,
            'LIMIT ' . $_SESSION['tmpval']['pos'] . ', '
            . $_SESSION['tmpval']['max_rows']
        );

williamdes avatar Nov 09 '19 19:11 williamdes

LIMIT clause must go before FOR UPDATE

williamdes avatar Nov 09 '19 19:11 williamdes

or should we add a limit to a FOR UPDATE clause ?

williamdes avatar Nov 09 '19 19:11 williamdes

Also using

UNION
SELECT ... FROm xxx WHERE YEAR(birthdate) < 1900 AND birthdate IS NOT NULL AND YEAR(birthdate) !=0;
SELECT ... FROm yyy WHERE YEAR(birthdate) < 1900 AND birthdate IS NOT NULL AND YEAR(birthdate) !=0;

williamdes avatar Nov 18 '19 10:11 williamdes