Skip to content

If Then Else

Mathias Rangel Wulff edited this page Jun 13, 2015 · 4 revisions

Keyword 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