|
|
|
ถ้าผมต้องการ query จากตาราง ไปเก็บไว้ใน database อีกตัวนึง ทำยังไงครับ |
|
|
|
|
|
|
|
Code (PHP)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<?php
//เชื่อม database
$connect1 = mysql_connect("localhost","root","root") or die (mysql_error());
mysql_select_db("punch_list");
$Str = "SELECT Deficiency.year_month_day , Deficiency.SiteID , Deficiency.Code ,
ms95.Major_Minor ,Deficiency.Number_Error ,ms95.Description , Deficiency.Short_description
FROM Deficiency, ms95
WHERE Deficiency.Code = MS95.Code";
mysql_query("SET NAMES utf8");
$query = mysql_query($Str,$connect1);
//เชื่อม database อีกตัวนึง
$connect2 = mysql_connect("localhost","root","root") or die (mysql_error());
mysql_select_db("Amount_of_Deficiency");
$obj = "INSERT INTO data(year_month_day,SiteID,Code,Major_Minor,Amount_deficiency,description,description_yourself)
VALUES Deficiency.year_month_day , Deficiency.SiteID , Deficiency.Code ,
ms95.Major_Minor ,Deficiency.Number_Error ,ms95.Description , Deficiency.Short_description";
echo $obj;
$objQUERY = mysql_query($obj,$connect2) ;
if($objQUERY&& mysql_num_rows($objQUERY) != 0 )
{
echo "<br>query complete";
}
else
{
echo "<br>query not complete";
}
?>
Tag : PHP, MySQL
|
ประวัติการแก้ไข 2013-05-30 16:31:57 2013-05-30 16:33:04
|
|
|
|
|
Date :
2013-05-30 16:30:29 |
By :
artsurasak |
View :
653 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
จัดไป
SQL INSERT ... SELECT
|
|
|
|
|
Date :
2013-05-30 17:40:10 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณครับ ADMIN
|
|
|
|
|
Date :
2013-05-30 18:25:47 |
By :
artsurasak |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|