ผู้เขียน หัวข้อ: ขอความช่วยเหลือ อ.MN การใช้ union  (อ่าน 2307 ครั้ง)

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

ออฟไลน์ yut

  • Sr. Member
  • ****
  • กระทู้: 498
  • Respect: 0
    • ดูรายละเอียด
ขอความช่วยเหลือ อ.MN การใช้ union
« เมื่อ: กรกฎาคม 02, 2008, 11:36:28 AM »
0
Value :=GetSQLintegerData('select count(p.person_id) from person p,house h,village v,person_epi p1,person_epi_nutrition p2'+
    ' where p.house_id=h.house_id'+
    ' and h.village_id = v.village_id'+
    ' and p2.nutrition_date between "'+ds1+'" and "'+ds2+'"'+
     ' and p1.person_epi_id = p2.person_epi_id '+
    ' and p.person_id=p1.person_id'+
    ' and p2.nutrition_level in ("1","2","3","4","5")'+
    ' and p.age_y<="5"'+
    ' and p.age_m<="11"'+
    ' and p.age_d<="30"'+
    ' and p.age_y is not null'+
    ' and v.village_id not in ("0")'+
    ' and p.house_regist_type_id = "1" and "3"' +

    'union '+
' select count(p.person_id) from person p,house h,village v,person_wbc p3,person_wbc_service p4'+
      ' where p.house_id=h.house_id and h.village_id = v.village_id'+
      ' and p3.person_wbc_id=p4.person_wbc_id'+
    ' and p4.service_date between "'+ds1+'" and "'+ds2+'"'+
      ' and p.person_id=p3.person_id'+
      ' and p4.nutrition_level in ("1","2","3","4","5")'+
      ' and p.age_y<="5"'+
      ' and p.age_m<="11"'+
      ' and p.age_d<="30"'+
      ' and p.age_y is not null'+
      ' and p.house_regist_type_id in ("1","3")' +
    ' and v.village_id = "'+DBPipeline['village_id']+'" ');

จากคำสั่งข้างต้น ผลที่ได้เป็นค่าเดียวกันทั้งหมดเลยครับ ไม่แยกจำนวนตามรายหมู่บ้านครับ
และได้จากคำสั่งที่เป็นคำสั่งชุดแรกเท่านั้นครับ

แต่เมื่อนำคำสั่งนี้ไปทดสอบใน  Query ได้คำตอบเป็น 2 ค่าครับ ช่วยชี้แนะด้วยครับ
สสอ.จตุรพักตรพิมาน จ.ร้อยเอ็ด 45180

doramon

  • บุคคลทั่วไป
Re: ขอความช่วยเหลือ อ.MN การใช้ union
« ตอบกลับ #1 เมื่อ: กรกฎาคม 02, 2008, 11:51:05 AM »
0
Value :=GetSQLintegerData(XXX)

มันก็แสดงค่าเดียวอยู่แล้วครับ


ผมว่าน่าจะอยู่ที่ฟอร์มด้วยครับ ส่งฟอร์มมาให้ดูด้วยครับ


ออฟไลน์ yut

  • Sr. Member
  • ****
  • กระทู้: 498
  • Respect: 0
    • ดูรายละเอียด
Re: ขอความช่วยเหลือ อ.MN การใช้ union
« ตอบกลับ #2 เมื่อ: กรกฎาคม 02, 2008, 12:02:04 PM »
0
ส่งให้แล้วครับ
สสอ.จตุรพักตรพิมาน จ.ร้อยเอ็ด 45180