Table Update problem!
Both tables contain serial numbers, device type fields.
I now want to update table two device type value for table one the same serial number device type value, ask how to write?
------Solution--------------------
$sql = ' SELECT * from table 2 ';
$res = mysql_query ($sql) or Die (' Query failed: '. mysql_error ());
while ($row = Mysql_fetch_array ($res)) {
$sql 1 = "SELECT * FROM table 1 where serial number = $row [' Serial number '] limit 1";
$res 1 = mysql_query ($sql 1) or Die (' Query failed: '. mysql_error ());
while ($row 1 = mysql_fetch_array ($res)) {
$sql 2 = "Update table 2 set Device Type value = $row 1[' device type value '] where serial number = $row [' Serial number ']";
mysql_query ($sql 2);
}
}
---------------
That's probably what it means. Change it yourself.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service