Using If else in SQL Select statement

后端 未结 11 1668
感情败类
感情败类 2020-12-24 05:35

I have a select statement which will return 2 columns.

ID | IDParent

Then in my program I have to test if IDParent is < 1 then use

11条回答
  •  庸人自扰
    2020-12-24 05:48

    You can also use a union construct. I'm not sure if CASE is a common SQL construct ...

    SELECT ID FROM tabName WHERE IDParent<1 OR IDParent IS NULL
    UNION 
    SELECT IDParent FROM tabName WHERE IDParent>1
    

提交回复
热议问题