ผู้เขียน หัวข้อ: สอบถามอาจารย์ทุกท่านเกี่ยวกับการใช้คำสั่ง sql update  (อ่าน 7713 ครั้ง)

0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

ออฟไลน์ Guitar-hero

  • Hero Member
  • *****
  • กระทู้: 605
  • Respect: 0
    • ดูรายละเอียด
    • โรงพยาบาลละแม,รพ.ละแม
คือผมต้องการปรับปรุงข้อมูลบางอย่างในตาราง ovst โดยปรับปรุงเฉพาะเดือนครับ คำสั่งที่ผมใช้เป็นดังนี้

update ovst set spclty='01'

where  main_dep='13' and vstdate between '2009-06-01' and '2009-06-01'

แต่มันดึึงมาทั้งหมดครับ มันไม่เลือกมาเฉพาะเดือนที่เลือก ไม่ทราบว่าผมเขียนคำสั่งผิดตรงไหน มือใหม่ครับ ช่วยแนะนำหน่อยครับ
จีระยุทธ ปิ่นสุวรรณ นักวิชาการคอมพิวเตอร์(พนักงานราชการ)
รพช.ละแม จ.ชุมพร
MASTER: HP Proliant Dl160 gen10
SLAVE: Dell PowerEdge T610 Quad core Intel 3.0G Ram 8GB Centos 5.9+Mysql 5.5

ออฟไลน์ skypec

  • Hero Member
  • *****
  • กระทู้: 1,469
  • Respect: +1
    • ดูรายละเอียด
    • โรงพยาบาลรือเสาะ
Re: สอบถามอาจารย์ทุกท่านเกี่ยวกับการใช้คำสั่ง sql update
« ตอบกลับ #1 เมื่อ: กุมภาพันธ์ 10, 2010, 22:35:20 PM »
0
ลองทดสอบแล้ว ข้อมูลก็มาเฉพาะวันที่กำหนดเองนะครับ
โรงพยาบาลรือเสาะ ( www.rusohospital.com )
Version HOSxP 3.53.7.28
Machine Server
Master : IBM
Slave   : HP

ออฟไลน์ saiphon

  • Sr. Member
  • ****
  • กระทู้: 431
  • Respect: 0
    • ดูรายละเอียด
Re: สอบถามอาจารย์ทุกท่านเกี่ยวกับการใช้คำสั่ง sql update
« ตอบกลับ #2 เมื่อ: กุมภาพันธ์ 10, 2010, 22:45:23 PM »
0
ก็น่าจะถูกต้องแล้วนะครับ
Admin Amnatcharoen
Server HP ProLiant ML350 G6  2.8 GHz Ram 12 GB
CentOS 5.3 , MYSQL 5.1.30 64bit จำนวน 2 เครื่อง
Server HP ProLiant ML350 G6  2.8 GHz Ram 8 GB
Windows Server 2003 , MYSQL 5.1.30 64bit จำนวน 1 เครื่อง
ขึ้นระบบ HOSxP PCU เมื่อ 1 เม.ย.52
ขึ้นระบบ Datacenter เมื่อ 15 มิ.ย.52 โดย อ.MN

ออฟไลน์ Svl2Nuk3

  • Hero Member
  • *****
  • กระทู้: 793
  • Respect: 0
    • ดูรายละเอียด
Re: สอบถามอาจารย์ทุกท่านเกี่ยวกับการใช้คำสั่ง sql update
« ตอบกลับ #3 เมื่อ: กุมภาพันธ์ 17, 2010, 00:34:18 AM »
0
น่าจะแก้ข้อมูลใน vn_stat   ด้วยนะครับ
เพราะหลาย ๆ รายงานมักจะดึงข้อมูลจากตารางนี้  เพื่อลดความซ้ำซ้อนของคำสั่งในการดึงข้อมูล
I'm nuke (นุ๊ก)
My Blog  : http://www.codenuke.net
อดีต นวก.คอมฯ รพช.พรหมพิราม => 1 พ.ค. 52 - 30 ก.ย. 54
ปัจจุบัน : Software Engineer บริษัทแห่งหนึ่ง

ออฟไลน์ yord

  • Hero Member
  • *****
  • กระทู้: 1,952
  • PATTANI HOSPITAL
  • Respect: +2
    • ดูรายละเอียด
    • http://www.pattanihos.com
Re: สอบถามอาจารย์ทุกท่านเกี่ยวกับการใช้คำสั่ง sql update
« ตอบกลับ #4 เมื่อ: กุมภาพันธ์ 22, 2010, 13:53:14 PM »
0
น่าจะได้แล้วนะครับ ของผมใช้แบบนี้
update ovst set spclty = '01' where main_dep = "052" and vstdate = "2009-04-09"
แต่ว่าช้าครับ กำลังจะทำแบบว่า ให้ update spclty ทั้งหมดที่ว่างอยู่ โดยให้ไปอิงกับ ตาราง kskdepartment เพราะว่ามี spclty ที่เป็นค่าว่า่งมากเหมือนกันครับ
ลองอยู่ 2 คำสั่งแต่ยังไม่ได้เลยครับ ;D
 ;Dupdate ovst set spclty =
(select spclty from kskdepartment where kskdepartment.dep = ovst.cur_dep)
where cur_dep in (select cur_dep from ovst where ovst.cur_dep = kskdepartment.dep and
ovst.spclty < "0" and ovst.vstdate = "2009-04-09")

update ovst set spclty = (select kskdepartment.spclty from kskdepartment,ovst
where kskdepartment.depcode=ovst.cur_dep)
where spclty < "0" and vstdate = "2009-04-09"
Mr.Yordying Kongkachan (yord02@gmail.com)
ADMIN PATTANI HOSPITAL  http://www.pattanihos.com
เริ่มใช้ HOSxP พฤศจิกายน 2549
(Master)IBM X3650 M3 QuardCord 3.06 1 CPU 20 GBs. of Ram (up to 68 GBs 29/06/56)
Linux 64bit MySQL 5.5.21 64bit (ด้วยความช่วยเหลือของ อ.บอยครับ)
(Slave1)HP ProLiant ML350 G6 Xeon E5530 2.04 20 GBs. Ram (up to 54 GBs 27/06/56)
Linux 64bit MySQL 5.1.30 64bit Database v.3.56.4.9 (29/06/56) client v.3.56.3.19

ออฟไลน์ yord

  • Hero Member
  • *****
  • กระทู้: 1,952
  • PATTANI HOSPITAL
  • Respect: +2
    • ดูรายละเอียด
    • http://www.pattanihos.com
Re: สอบถามอาจารย์ทุกท่านเกี่ยวกับการใช้คำสั่ง sql update
« ตอบกลับ #5 เมื่อ: กุมภาพันธ์ 23, 2010, 15:20:58 PM »
0
วันนี้ก็ยังไม่ได้เหมือนกัน ;D
ขอดันครับ เผื่อ อ.ท่านใดทำได้แล้วครับะ ;D
Mr.Yordying Kongkachan (yord02@gmail.com)
ADMIN PATTANI HOSPITAL  http://www.pattanihos.com
เริ่มใช้ HOSxP พฤศจิกายน 2549
(Master)IBM X3650 M3 QuardCord 3.06 1 CPU 20 GBs. of Ram (up to 68 GBs 29/06/56)
Linux 64bit MySQL 5.5.21 64bit (ด้วยความช่วยเหลือของ อ.บอยครับ)
(Slave1)HP ProLiant ML350 G6 Xeon E5530 2.04 20 GBs. Ram (up to 54 GBs 27/06/56)
Linux 64bit MySQL 5.1.30 64bit Database v.3.56.4.9 (29/06/56) client v.3.56.3.19

ออฟไลน์ yord

  • Hero Member
  • *****
  • กระทู้: 1,952
  • PATTANI HOSPITAL
  • Respect: +2
    • ดูรายละเอียด
    • http://www.pattanihos.com
0
ท่านใดลองแล้วได้ผล รบกวนด้วยครับ ???
เพราะฟิลด์คลินิก ของผมว่างเยอะครับ(เกิดจากตอนนัด แล้วไม่ได้ใส่คลินิก เมื่อส่ง visit ล่วงหน้าก็เลยไม่มี คลินิกออกมาน่ะครับ) เดี๋ยวส่งข้อมูลแล้วมีปัญหาน่ะครับ ;D ;D ;D
Mr.Yordying Kongkachan (yord02@gmail.com)
ADMIN PATTANI HOSPITAL  http://www.pattanihos.com
เริ่มใช้ HOSxP พฤศจิกายน 2549
(Master)IBM X3650 M3 QuardCord 3.06 1 CPU 20 GBs. of Ram (up to 68 GBs 29/06/56)
Linux 64bit MySQL 5.5.21 64bit (ด้วยความช่วยเหลือของ อ.บอยครับ)
(Slave1)HP ProLiant ML350 G6 Xeon E5530 2.04 20 GBs. Ram (up to 54 GBs 27/06/56)
Linux 64bit MySQL 5.1.30 64bit Database v.3.56.4.9 (29/06/56) client v.3.56.3.19

ออฟไลน์ yord

  • Hero Member
  • *****
  • กระทู้: 1,952
  • PATTANI HOSPITAL
  • Respect: +2
    • ดูรายละเอียด
    • http://www.pattanihos.com
0
ตอนนี้ก็ทำแบบนี้ไปก่อนครับ  ;D
update ovst set spclty = "01" where (main_dep = "002" or main_dep = "003" or main_dep ="007" or main_dep = "009" or main_dep = "010" or main_dep = "012" or main_dep = "013" or main_dep = "014" or main_dep = "015" or main_dep = "016" or main_dep = "017" or main_dep = "019" or main_dep = "020" or main_dep = "021" or main_dep = "025" or main_dep = "027" or main_dep = "029" or main_dep = "030" or main_dep = "033" or main_dep = "039" or main_dep = "040" or main_dep = "043" or main_dep = "044" or main_dep = "049" or main_dep = "050" or main_dep = "061" or main_dep = "064" or main_dep = "065" or main_dep = "070" or main_dep = "071" or main_dep = "072" or main_dep = "073" or main_dep = "074" or main_dep = "076" or main_dep = "079" or main_dep = "084" or main_dep = "111" or main_dep = "112" or main_dep = "113" or main_dep = "124") and spclty < "0" and (vstdate between "2009-10-01" and "2009-10-31")
ประมาณนี้ อ่ะครับ ข้อมูลจะได้สมบูรณ์  ;D ;D ;D
Mr.Yordying Kongkachan (yord02@gmail.com)
ADMIN PATTANI HOSPITAL  http://www.pattanihos.com
เริ่มใช้ HOSxP พฤศจิกายน 2549
(Master)IBM X3650 M3 QuardCord 3.06 1 CPU 20 GBs. of Ram (up to 68 GBs 29/06/56)
Linux 64bit MySQL 5.5.21 64bit (ด้วยความช่วยเหลือของ อ.บอยครับ)
(Slave1)HP ProLiant ML350 G6 Xeon E5530 2.04 20 GBs. Ram (up to 54 GBs 27/06/56)
Linux 64bit MySQL 5.1.30 64bit Database v.3.56.4.9 (29/06/56) client v.3.56.3.19