我的记录中有四个交费日期的字段(jfrq_a,jfrq_b,jfrq_c,jfrq_d),我想将在一段时间内交费的记录全都查询出来,SQL应该怎么写?(注:因为有些用户是一次交清,有些用户
是分四次来交费,就是说有些交费日期字段是空的,有些是有的)我想了很长时间,试了很多次,好像都不行啊

解决方案 »

  1.   

    select * from table
     where jfrq_a is not null
    union select * from table
     where jfrq_b is not null
    union select * from table
     where jfrq_c is not null
    union select * from table
     where jfrq_d is not null
      

  2.   

    说说这四个字段的意思jfrq_a,jfrq_b,jfrq_c,jfrq_d
    你是否也要把交费日期为空也的要查出来?
      

  3.   

    select * from table
     where jfrq_a between(d1,d2) or jfrq_b between(d1,d2) or jfrq_c between(d1,d2) or jfrq_d between(d1,d2)
      

  4.   

    select * from tablewhere (jfrq_a is not null)or(jfrq_b is not null)or
          (jfrq_c is not null)or(jfrq_d is not null)
      

  5.   

    sorry,没看清有时间段,请使用我楼上的: flyingkiller(大飞虫)
      

  6.   

    SELECT * FROM Table
    WHERE (jfrq_a BETWEEN DateBegin AND DateEnd) OR
          (jfrq_b BETWEEN DateBegin AND DateEnd) OR
          (jfrq_c BETWEEN DateBegin AND DateEnd) OR
          (jfrq_d BETWEEN DateBegin AND DateEnd)
    DateBegin和DateEnd就是你要的这段时间的起始日期和终止日期。
    如果这四个字段中有一个字段的日期值是在你指定的起止日期范围内,就列出这些记录。
    我没理解错吧?
      

  7.   

    同意  flyingkiller(大飞虫) !
    这样一来,觉得没什么值得你想几天的哦!
    (猜:除非,相同的客户要累计SUM)
      

  8.   

    同意 yekehe(河子)这个表是有问题的。