当我执行查询时,我在国家专栏中获得国际描述?

时间:2017-05-12 06:01:03

标签: mysql

enter image description here

我编写了查询以仅获取国内电话和说明。但是,当我执行以下查询时。

我正在获得国家和国际.Below前缀只是为了获得国家。请帮助我解决问题,因为我是SQL的新手。

在国家专栏中,零,不应该打印,因为它们是国际性的。

select ce.destination_descr,ce.duration,
      if (length(ce.destination_number)>5 
          and (ce.destination_number REGEXP '32|3246|3247|3248|3249|3270|3277|3278|32900|32901|32902|32903|32904|32905|32906|32907|32908|32909|1207|1307|1407|1204|1304|1404|1200|1300|1400|1299|1399|1499|100|119'),
          ce.cost,0) as national 
from symphonica_cdr_event ce 
join order_process op on op.order_id=ce.order_id 
where op.invoice_id=8604

1 个答案:

答案 0 :(得分:0)

如果我理解正确,您只想获得上述前缀中包含destination_number的那些呼叫信息。要实现这一点,你应该在where子句中使用compare 其中ce.destination_number REGEXP '32 | 3246 | 32 ..'以及长度条件应该在where子句之后。 就像这样。

    select ce.destination_descr,ce.duration,ce.cost from symphonica_cdr_event ce join order_process op on op.order_id=ce.order_id where op.invoice_id=8604 and length(ce.destination_number)>5 and ce.cost>0
and (ce.destination_number REGEXP '^(32|3246|3247|3248|3249|3270|3277|3278|32900|32901|32902|32903|32904|32905|32906|32907|32908|32909|1207|1307|1407|1204|1304|1404|1200|1300|1400|1299|1399|1499|100|119)')