Is it possible to be paid by a company for research and also use this research towards a Ph.D.? The question in this link makes the assumption that the work you do at a private company and the work you do at a university for a Ph.D. do not intersect (or have very little in common), thus the person asks if "it is too much work or stress" to do both.  This question (and its answer) got me to think of another related question.

My Question: I'm wondering if the research you do for a private company can be used towards a Ph.D.? For example, suppose I work for a private company X and I have been accepted into the Ph.D. program at university Y.  

Is it possible to be paid by company X for your research work, but at the same time use that research work to publish a paper along with your advisor at university Y?

I think I already know the answer to the question: It's possibly only if your advisor at university Y and your supervisor at company X have a strong relationship of many years and trust each other.  

But I'm wondering if there are other answers? 

Some background information about me: I have 10+ years of software engineering experience. I have a two B.S. degrees (Computer Engineering and Mathematics), one M.S. degree (Software Engineering), and a 2nd M.S. on the way in 2020 (Electrical Engineering).  My plan is indeed to pursue a Ph.D. in Electrical Engineering in 2020.
Yes, you can do this, but use caution. There are situations in which you can do research at a company but be prohibited from writing about it or using it outside the company. Contracts rule in this area. 

There are other situations in which you can do such research and have the university involved so that you can use the research to obtain a degree, but your dissertation disappears into the void and you can't publish anything, again for contractual reasons. 

If the work you do can be patented, there may be additional restrictions on who owns the patents (likely not you) and who can benefit from it (possibly you, but not necessarily). 

Other places there are no issues. 

So, before you contemplate doing this, just be aware of any restrictions on your results and what you can do with them after your relationships to both company and university end. 

And, if you have a contractual obligation, be sure to honor it as companies can be ruthless if you expose proprietary work or trade secrets.