BMS-HOSxP Community
HOSxP => แจ้งปัญหา / ขอความช่วยเหลือ => ข้อความที่เริ่มโดย: yossak ที่ กุมภาพันธ์ 12, 2013, 14:17:41 PM
-
ผมต้องการปรับข้อมูล โดยใช้คำสั่ง update ถ้าตารางเดียว ก็ทำได้อยู่แต่ขอพวง 2ตารางมามันเปลี่ยนไม่ได้ต้องใช้คำสั่งไรครับ
SELECT person.house_id, house.village_id, person.pname, person.fname,
person.lname, person.age_y, person.age_m ,person.house_regist_type_id
FROM person INNER JOIN
house ON person.house_id = house.house_id
where person.house_regist_type_id in (1,3)
and house.village_id in (6,7,8,9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,52,53,54,55,56,57,58,59,62,65)
แบบนี้ครับ แต่ใช้คำว่า update แทน select
update person set person.house_regist_type_id = '4'
FROM person INNER JOIN
house ON person.house_id = house.house_id
where person.house_regist_type_id in (1,3)
and house.village_id in (6,7,8,9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,52,53,54,55,56,57,58,59,62,65)
แล้ว มัน error ไม่ยอมทำตามคำสั่ง
-
ทำไมไม่ใช่หมู่บ้านในตาราง person เลยครับ
-
update person
INNER JOIN house ON person.house_id = house.house_id
set person.house_regist_type_id = '4'
where person.house_regist_type_id in (1,3)
and house.village_id in (6,7,8,9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,52,53,54,55,56,57,58,59,62,65)
น่าจะได้นะ ;D
-
อิอิ จริงๆด้วย ;D ขอบคุณครับ เกื้อกูล ลืมดู