mysql_connect("localhost","root","");
mysql_select_db("database1");
mysql_query("INSERT INTO database2.categories (category_name,description,group_id,created)
SELECT table1.name, table1.description, 12, UNIX_TIMESTAMP()
FROM GiveArang_categories Where `p_id`= '225' ");
I need to insert data into the second database which is selected from the first database. Both databases have different connections. It needs to done in php in a single query .