I need a query where if a column from a row was filled, return her, else return another column value in the same table.
This code will insert like a subquery, so, I need that return just only value.
**
Data Base Exemple**
ID | Name | LastName |
---|---|---|
1 | Maria | Nunes |
2 | Null | Torres |
Expected query
SELECT *,
(*new subquery FROM TableName) AS Name,
FROM
Table2.
Expected response
ID | Name |
---|---|
1 | Maria |
2 | Torres |
Actually, I get the two values from columns and mount an object with "if statement" separately to check if value is difference of "null"
2
Answers
You may need to use CASE statement.
Try with
COALESCE
: