How to merge column in mysql depending on match I have one table which looks like this in mysql 

column1  column2    name    column3 data
1          1        foo     1       1.5
1          1        foo     2       2.5
1          1        foo     3       3.5
1          1        foo     4       4.5
1          1        foo2    1       1.1
1          1        foo2    2       3.5
1          1        foo3    3       5.6
1          1        foo3    4       6.7


I want to do query like something like this, I really don't know how to write as I am new to mysql

select name from mytable where name = 'foo' or name = 'foo2'or name = 'foo3' 


I expect output to be like this 

column1 column2 column3    foo    foo2  foo3
1       1         1        1.5     1.1  NaN
1       1         2        2.5     3.5  NaN
1       1         3        3.5     NaN  5.6
1       1         4        4.5     NaN  6.7


Is it possible in mysql ?
SELECT column1,column2,column3
MAX(CASE WHEN name='foo' THEN data ELSE 0 END)as foo,
MAX(CASE WHEN name='foo2' THEN data ELSE 0 END)as foo2,
MAX(CASE WHEN name='foo3' THEN data ELSE 0 END)as foo3
FROM tableName
GROUP BY column3