Using If else in SQL Select statement
SELECT CASE WHEN IDParent < 1
THEN ID
ELSE IDParent
END AS colname
FROM yourtable
Here, using CASE Statement
and find result:
select (case when condition1 then result1
when condition2 then result2
else result3
end) as columnname from tablenmae:
For example:
select (CASE WHEN IDParent< 1 then ID
else IDParent END) as columnname
from tablenmae
you can use CASE
SELECT ...,
CASE WHEN IDParent < 1 THEN ID ELSE IDPArent END AS ColumnName,
...
FROM tableName