Say i am having a table and some values like the following.
-----------------------------------------
| col1 | col2 | col3 | col4 | col5 |
---------|------|-------|-------|--------
| 6171368 | 1 | TEST | 12053 | 123456 |
-----------------------------------------
| 6171368 | 2 | ABCD | QWERT | |
-----------------------------------------
What i want to do is i need to get value of col5 of 1 row if value of col5 is empty without using where conditon exclude where col2 = 2. When i tried with a query i am getting an error saying
1242 - Subquery returns more than 1 row
My query is
SELECT col1,col2,col3,col4,
if (col5 IS NULL or col5 = '' ,
(
select col5 from table
where col2 = 1
group by col1
),'') as col5