 |
|
ผมต้องการ Loop เอาข้อมูลที่ไม่ช้ำกัน ผมไช้ Oracle Database ครับ |
|
 |
|
|
 |
 |
|
ขอความช่วยเหลือ ด้วยครับ
|
 |
 |
 |
 |
Date :
2015-07-30 13:33:18 |
By :
thone16 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตัวไหนก็ได้
Code
select s.msisdn,h.complete_date, r.busi_type,r.busi_remark
from HIS_ORDERINFO h,inf_subscriber_all s,RUL_BUSINESS_CODE r
where h.sub_id=s.sub_id
and r.busi_type=h.order_type
and (r.busi_type='CB050' or r.busi_type='CD013')
and s.msisdn='2028580109'
เอามาตัวเดียว
Code
select s.msisdn,h.complete_date, r.busi_type,r.busi_remark
from HIS_ORDERINFO h,inf_subscriber_all s,RUL_BUSINESS_CODE r
where h.sub_id=s.sub_id
and r.busi_type=h.order_type
and r.busi_type='CD013'
and s.msisdn='2028580109'
|
 |
 |
 |
 |
Date :
2015-07-30 13:49:25 |
By :
ipstarone |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่ใช่...
|
 |
 |
 |
 |
Date :
2015-07-30 14:22:54 |
By :
thone16 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คือแบบว่า ผมอยากจะ วน loop
ฤ้าเจี s.msisdn='2028580109' ที่มี r.busi_type='CD013'
แล้วไม่เอา s.msisdn='2028580109' ที่มี r.busi_type='CB050'
แบบนี้ ครับ
ขอบคุญ ครับ
|
 |
 |
 |
 |
Date :
2015-07-30 14:30:56 |
By :
thone16 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2015-07-30 14:44:23 |
By :
thone16 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่ได้ อไรเลย...
ขอบคุญ ครับ
|
 |
 |
 |
 |
Date :
2015-07-30 15:00:03 |
By :
thone16 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มี primary key หรือ unique key ไหมครับ
แบบ มี pk หรือ uk
Code (SQL)
select tb.* from table as tb where pk=(select min(pk) from table where msisdn=tb.msisdn)
|
 |
 |
 |
 |
Date :
2015-07-30 18:23:04 |
By :
NewbiePHP |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เดียวจะลองดู
ขอบคุณครับ คุณ NewbieXYZ
|
 |
 |
 |
 |
Date :
2015-07-31 08:46:21 |
By :
thone16 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|