|
 |
|
ถามผู้รู้อีกทีนะคะ มึงตึ๊บจริง ๆ เอาโครงงานเลยนะคะ มี 2 ตาราง ฟิลด์เหมือนกันเด๊ะเลยค่ะ ทั้ง id และ name |
|
 |
|
|
 |
 |
|
แป่วว ทำตามสองกระทู้นี้ยังไม่ได้หรือครับ แล้วก็อย่าตั้งกระทู้ใหม่เลยครับเอากระทู้เดิมนี่แหละไม่งั้นหากันงงครับ
https://www.thaicreate.com/php/forum/028505.html
https://www.thaicreate.com/php/forum/028509.html
|
 |
 |
 |
 |
Date :
2009-06-23 10:32:18 |
By :
num |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
น้องเขียนตามนี้แล้วนะคะ ตรงช่อง idclaim ของ secondtb ไม่มีค่า idclaim ของ main_tb มาเลยค่ะ พี่ num คะ ผิดตรงไหนเหรอคะ
UPDATE main_tb,secondtb SET secondtb.idclaim = main_tb.idclaim WHERE secondtb.name=main_tb.name_send;
|
 |
 |
 |
 |
Date :
2009-06-23 10:40:53 |
By :
น้องเอ๋ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองโค้ดนี้ดูนะครับ ก็เหมือนๆ กับข้างบนครับ แต่อาจจะต่างกันตรงที่โครงสร้างของตารางก็ได้ครับ
CREATE TABLE `a1` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(100) DEFAULT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `a1`(`id`,`name`) VALUES (1,'aaa'),(2,'bbb'),(3,'ccc'),(4,'ddd');
CREATE TABLE `a2` (
`name` VARCHAR(100) DEFAULT NULL,
`id` INT(11) DEFAULT NULL
);
INSERT INTO `a2`(`name`,`id`) VALUES ('aaa',NULL),('bbb',NULL),('ccc',NULL),('ddd',NULL);
UPDATE a1,a2 SET a2.id = a1.id WHERE a1.name=a2.name;
|
 |
 |
 |
 |
Date :
2009-06-23 11:05:21 |
By :
num |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|