BMS-HOSxP Community
HOSxP => แจ้งปัญหา / ขอความช่วยเหลือ => ข้อความที่เริ่มโดย: panus_t ที่ กุมภาพันธ์ 17, 2011, 14:28:29 PM
-
มีตารางไหนที่แยก ชื่อภาษาไทย ต. อ.และ จ. เป็นคนละคอลัม บ้างครับ
แบบว่าอย่างได้คนละคอลัม เพื่อทำจดหมายเวียน (เพื่อความสวยงาม ต้องอยู่คนละบรรทัด)
;D ;D
-
นำเข้าตาราง amp, tambon จาก hcis ด้วยไหมล่ะครับ..ได้ตรงตามใจเลย..
-
ลองเอาไปดูครับของผมแก้thaiaddressเลยหุหุ
-
ทดสอบใช้คำสั่งใน Sql นี้ดูซิครับ
ถ้าเอาทั้งหมดก็ตัด limit 100 ออกครับ
select t.*,t1.name,t2.name,t3.name
from thaiaddress t
left outer join thaiaddress t1 on t1.chwpart = t.chwpart and t1.codetype = 1
left outer join thaiaddress t2 on concat(t2.chwpart,t2.amppart) = concat(t.chwpart,t.amppart) and t2.codetype = 2
left outer join thaiaddress t3 on t3.addressid = t.addressid and t3.codetype = 3
limit 100
-
ลองเอาไปดูครับของผมแก้thaiaddressเลยหุหุ
ผมลองลบ ข้อมูลในตารางแล้ว Appen ใหม่ไม่ได้ครับ งง ???
-
ทดสอบใช้คำสั่งใน Sql นี้ดูซิครับ
ถ้าเอาทั้งหมดก็ตัด limit 100 ออกครับ
select t.*,t1.name,t2.name,t3.name
from thaiaddress t
left outer join thaiaddress t1 on t1.chwpart = t.chwpart and t1.codetype = 1
left outer join thaiaddress t2 on concat(t2.chwpart,t2.amppart) = concat(t.chwpart,t.amppart) and t2.codetype = 2
left outer join thaiaddress t3 on t3.addressid = t.addressid and t3.codetype = 3
limit 100
ถ้าผมใช้คำสั่งนี้อยู่แล้วจะนำมา Mix กันทำไง
select h.hospcode,concat(h.chwpart,h.amppart,h.tmbpart) as aid,h.hospital_type_id,h.hosptype,h.name,th.full_name,h.moopart,h.chwpart,h.amppart,h.tmbpart
from hospcode h
left outer join thaiaddress th on th.addressid=concat(h.chwpart,h.amppart,h.tmbpart)
where hospital_type_id in ("2","5","6","7","11","12","15")
-
รู้แล้วต้องเพิ่มฟิลด์ก่อน
alter table thaiaddress add cname varchar(50)
แบบนี้ไม่รู้ว่าถูกหรือเปล่า
-
select h.hospcode,concat(h.chwpart,h.amppart,h.tmbpart) as aid,h.hospital_type_id,h.hosptype,h.name,th.full_name,h.moopart,h.chwpart,h.amppart,h.tmbpart,
th.name as tmb , th_amp.name as amp , th_chw.name as chw
from hospcode h
left outer join thaiaddress th on th.addressid=concat(h.chwpart,h.amppart,h.tmbpart)
left outer join thaiaddress th_amp on th_amp.addressid=concat(h.chwpart,h.amppart,"00")
left outer join thaiaddress th_chw on th_chw.addressid=concat(h.chwpart,"0000")
where hospital_type_id in ("2","5","6","7","11","12","15")
ถ้าจำชื่อฟิลไม่ผิดน่าจะประมาณนี้นะครับ
เดี๋ยวมีเครื่องลอรันโค้ดจะลองดูให้อีกทีครับ
-
ขอโทษทีครับโครงสร้างตารางthaiaddressของผม
CREATE TABLE `thaiaddress` (
`addressid` varchar(6) NOT NULL DEFAULT '',
`name` varchar(50) DEFAULT NULL,
`chwpart` char(2) DEFAULT NULL,
`amppart` char(2) DEFAULT NULL,
`tmbpart` char(2) DEFAULT NULL,
`codetype` char(1) DEFAULT NULL,
`pocode` varchar(5) DEFAULT NULL,
`full_name` varchar(250) DEFAULT NULL,
`tname` varchar(45) DEFAULT NULL,
`aname` varchar(45) DEFAULT NULL,
`cname` varchar(45) DEFAULT NULL,
PRIMARY KEY (`addressid`),
KEY `amppart` (`amppart`),
KEY `chwpart` (`chwpart`),
KEY `codetype` (`codetype`),
KEY `name` (`name`),
KEY `tmbpart` (`tmbpart`)
) ENGINE=InnoDB DEFAULT CHARSET=tis620