lundi 4 mars 2019

IF ELSE with local variable as condition MYSQL [duplicate]

This question already has an answer here:

I have a code like this.

SET @empty = 0;
IF (@empty = 0)
THEN
    insert into ComputeTasking.Response SET RequestTaskID=@rid,`ResponseJSON`=@JSON;
ELSE
    insert into ComputeTasking.Response SET `ResponseJSON`=@JSON;

END IF;

This returns error

[ERROR in query 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 'IF (@empty)
THEN
    select @empty' at line 1

What should I do here?

Thank you!

Aucun commentaire:

Enregistrer un commentaire