- 
                Notifications
    You must be signed in to change notification settings 
- Fork 689
If Then Else
        Mathias Rangel Wulff edited this page Jun 13, 2015 
        ·
        4 revisions
      
    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
© 2014-2024, Andrey Gershun & Mathias Rangel Wulff
Please help improve the documentation by opening a PR on the wiki repo