how to insert same data into two tables in mysql

aaat1

New Member
dear all. is this possible if i want to insert some data into two tables simultanously?but at \[code\]table2\[/code\] i'm just insert selected item, not like \[code\]table1\[/code\] which insert all data.This the separate query:\[code\]$sql = "INSERT INTO table1(model, serial, date, time, qty) VALUES ('star', '0001', '2010-08-23', '13:49:02', '10')"; $sql2 = "INSERT INTO table2(model, date, qty) VALUES ('star', '2010-008-23', '10')"; \[/code\]can i insert \[code\]COUNT(model)\[/code\] at table2? i have found some script, could i use this?\[code\]$sql = "INSERT INTO table1(model, serial, date, time, qty) VALUES ('star', '0001', '2010-08-23', '13:49:02', '10')";$result = mysql_query($sql,$conn);if(isset($model)){ $model = mysql_insert_id($conn); $sql2 = "INSERT INTO table2(model, date, qty) VALUES ('star', '2010-008-23', '10')"; $result = mysql_query($sql,$conn);}mysql_free_result($result);\[/code\]
 
Back
Top