Skip to content

If Then Else

Andrey Gershun edited this page May 28, 2015 · 4 revisions

IF THEN ELSE

Syntax:

    IF expression THEN statement1 [ELSE statement2]

For example:

    IF EXISTS(SELECT * FROM one WHERE a=10) 
       UPDATE one SET b = 200 WHERE a=10
    ELSE 
       INSERT INTO one VALUES (5,500);

Try this Alasql example in jsFiddle.

See also: CASE

Clone this wiki locally