php - mysql copy value from temp_table to table -


1 have 2 table, temp_table , table, both myisam.

temp_table (write frequently, run cron job every minute insert data)

id(auto_increment),title(varchar(200)),content(varchar(500)),date(datetime), mykey(tinyint(1) default 1) 

table (read frequently, custom search, update temp_table cron job every 10 minutes)

id(int(11)),title(varchar(200)),content(varchar(500)),date(datetime), hour(smallint(2)) 

now, data ~300mb/table , every update transfer 2,000-3,000 rows.

require dirname(__file__) . '/../connection.php'; mysql_select_db("news",$connextion); mysql_query("set names utf8"); $query = mysql_query("insert table (hour,id,title,content,date) values '".date('h')."',select id, title,content,date temp_table mykey = '1'"); $query = mysql_query("update temp_table set mykey='2' mykey = '1'"); //if data has transfer, update mykey='2' mark. mysql_close($connextion); 

but nothing insert table, how write correct mysql query , way more efficient? need less mysql connection time , lower memory usage. thanks.

ps: temp_table has rule checking if title duplicate, temp_table can not delete, , table cleared every day if date 1 month ago.

try using $query = mysql_query("insert table (hour,id,title,content,date) values ('".date('h')."',select id, title,content,date temp_table mykey = '1'")) or die('error while inserting');


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -