PHP Select Statement into a array

I am trying to do a two step process (1) select the DB key into an array that (2) will be used to feed another query.

example

Select ID from file1, file2 where file1.id = file2.id (will yeild 
multiple items) into an array var called $emailList = array();

then use the array var $emailList to select data using this sql statement SELECT id, name, address, phone from file1 where id in ($emailList) for processing a loop.

Base on my understanding, you are doing query on the same database right? If so, then why not just use a join statement.

If you don't know it yet, then you can refer to this http://www.codeproject.com/Articles/33052/Visual-Representation-of-SQL-Joins

You can use a subquery for the IN clause, as is defined in the docs. So:

SELECT id,
       name,
       address,
       phone
FROM file1
WHERE id IN
    (SELECT ID
     FROM file1
     INNER JOIN file2
         ON file1.id = file2.id)

is valid.