How do I insert the result (colume1) from this query to another table?
SELECT colume1 FROM table1 ORDER BY count DESC
| SitePoint Sponsor |

How do I insert the result (colume1) from this query to another table?
SELECT colume1 FROM table1 ORDER BY count DESC
Trigger8
**************************
I killed a 6-pack just to watch it die!


With or without the use of PHP? Has the other table already been created with the appropriate field specifications?

Let's assumed that another table is already there named table2, and the column named column2.
Trigger8
**************************
I killed a 6-pack just to watch it die!


I suppose this could be a solution. Haven't tested it, but it should work.
PHP Code:
$query = mysql_query("select column1 from table1");
while ($result = mysql_fetch_object($query)) {
mysql_query("insert into table2 (column2) values ('".$result->column1."')");
}
Bookmarks