My "files" table data is 

```
fileid   file1      file2
  1      abc.pdf    abcde.pdf
  2      ghf.pdf    ghfjkl.pdf
  3      hjy.pdf    hjyui.pdf

```

my "sampletable" data is

```
 fileid       names
   1           abc
   2           ghf
   3           hjy
   4           juk

```

I need output like 

```
   fileid      names    files

     1          abc      abc.pdf
     1          abc      abcde.pdf
     2          ghf      ghf.pdf
     2          ghf      ghfjkl.pdf
     3          hjy      hjy.pdf
     3          hjy      hjyui.pdf

```

i tried the following query but not getting desired output

```
 select st.fileid,st.contolnames,
 case when st.fileid in (select fileid from Files) 
 then f.file1 
 when st.fileid in (select fileid from Files)  then f.file2 end as Files
 from sampletable st
 join Files f on f.fileid=st.fileid 

```

Please help with this
demo: 
<https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=08337e2ee351b573bc902f06fcfba272>