一些SQL操作語句(5),幾個修改
返回
TABLE main_type1,DWG'XXXDWG'追加
use strict;
use DBI;
my(%t,$n,@fld,@rec,$pref);
# 連接數(shù)據(jù)庫
$$pref{dsn} = "DBI:mysql:host=localhost;database=cookbook";
$$pref{dbh} = DBI->connect($$pref{dsn}, "cbuser", "cbpass") or die "Cannot connect to server\n";
$$pref{dbh}->do("SET NAMES utf8");
if(!$$pref{dbh}){
print "SQL read ERROR!\n";
exit;
}
# 取出main_type1的編號
@{ $t{ptables} } = ();
$t{sth} = $$pref{dbh}->prepare("SELECT id,DWG FROM main_type1 WHERE DWG LIKE \'=\%\'");
$t{sth}->execute;
while ( @rec = $t{sth}->fetchrow_array ) {
push(@{ $t{ids} }, $rec[0]);
$t{dwg1} = "XXXDWG" . $rec[1];
push(@{ $t{DWGs} }, $t{dwg1});
}
$t{sth}->finish;
# 置換
for $n ( 0 .. $#{ $t{ids} } ) {
$t{id1} = $t{ids}[$n];
$t{dwg1} = $t{DWGs}[$n];
$t{sql} = 'UPDATE main_type1 SET DWG = "';
$t{sql} .= $t{dwg1} . '" where id = ';
$t{sql} .= $t{id1};
$t{DO} = $$pref{dbh}->do($t{sql});
print "$t{id1}=>$t{sql}=>DO=$t{DO}\n";
}
# 關(guān)閉數(shù)據(jù)庫
$$pref{dbh}->disconnect;
-----------------------------------------
DWG: =SC-2884-1
DWG: XXXDWG=D10439
UPDATE main_type1 SET DWG = "XXXDWG=SC-2884-1" WHERE id = 2421;
UPDATE main_type1 SET DWG = "XXXDWG" WHERE DWG is NULL;
-----------------------------------------
quo2和enq2的Delivery time合并(取消)
mysql> show columns from quo2;
+-----------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+---------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| time | date | YES | | NULL | |
| ORIGINid | int(11) | YES | | NULL | |
| PRICEid | int(11) | YES | | NULL | |
| PAYMENTid | int(11) | YES | | NULL | |
| DELIVERY | text | YES | | NULL | |
| money | int(11) | YES | | NULL | |
| percent0 | int(11) | YES | | NULL | |
| discount0 | int(11) | YES | | NULL | |
| percent | text | YES | | NULL | |
| discount | text | YES | | NULL | |
| price | text | YES | | NULL | |
| D_FEE | text | YES | | NULL | |
| total | text | YES | | NULL | |
| memo | text | YES | | NULL | |
| disc0 | int(11) | YES | | NULL | |
| disc | text | YES | | NULL | |
| price0 | text | YES | | NULL | |
+-----------+---------+------+-----+---------+----------------+
18 rows in set (0.02 sec)
mysql> show columns from enq2;
+------------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| time | date | YES | | NULL | |
| enq1id | int(11) | YES | | NULL | |
| LANGUAGEid | int(11) | YES | | NULL | |
| ORIGINid | int(11) | YES | | NULL | |
| PRICEid | int(11) | YES | | NULL | |
| PAYMENTid | int(11) | YES | | NULL | |
| makerid | int(11) | YES | | NULL | |
| DELIVERY | text | YES | | NULL | |
| type1id | text | YES | | NULL | |
| partsid | text | YES | | NULL | |
| QTY | text | YES | | NULL | |
| memo | text | YES | | NULL | |
| price | text | YES | | NULL | |
| discount | text | YES | | NULL | |
| discount0 | int(11) | YES | | NULL | |
| money | int(11) | YES | | NULL | |
| price1 | text | YES | | NULL | |
| makerref | text | YES | | NULL | |
| disc | text | YES | | NULL | |
| charges | text | YES | | NULL | |
+------------+---------+------+-----+---------+----------------+
21 rows in set (0.05 sec)
返回
岑溪市|
滦南县|
柳江县|
辽阳市|
游戏|
密山市|
永修县|
文化|
民县|
丰镇市|
永宁县|
宜城市|
哈尔滨市|
宁陵县|
广丰县|
马关县|
孝昌县|
施甸县|
阿城市|
内黄县|
田东县|
红河县|
阳高县|
松阳县|
南靖县|
南漳县|
利辛县|
松滋市|
惠州市|
嘉峪关市|
肇东市|
胶州市|
宁波市|
汉川市|
太仓市|
福州市|
鄂托克旗|
饶阳县|
舒兰市|
丰镇市|
环江|