本帖最后由 asiawen 于 2010-02-27 00:08:30 编辑

解决方案 »

  1.   

    前没有select cdate(操作日期)啊。
      

  2.   

    前一句有没有CDATE都不行,估计把数据库弄成日期型是没问题的,但这样改动比较多,想通过CDATE实现,请高手们指点。
      

  3.   

    提示的错误为“order by 表达式 (cdate(操作日期))包括当前查询未选定的字段。只有第一次查询所包含……………………”
    烦啊,难道用了union排序的时候就不能用函数吗,高手们指点啊
      

  4.   

    没测试,仅供参考。sql = "select * from(select * from 车辆排班 where instr(车牌,'" & a & _
          "') and 日期 <>null and cdate('" & b & "')>=cdate(操作日期) Union All " & _
          "select * from 车辆排班二 where instr(车牌,'" & a & _
          "') and 日期 <>null and cdate('" & b & "')>=cdate(操作日期)) order by cdate(操作日期) desc"
      

  5.   

    sql = "select * from(select * from 车辆排班 where instr(车牌,'" & a & _
          "') and 日期 <>null and cdate('" & b & "')>=cdate(操作日期) Union All " & _
          "select * from 车辆排班二 where instr(车牌,'" & a & _
          "') and 日期 <>null and cdate('" & b & "')>=cdate(操作日期)) order by cdate(操作日期) desc"
      

  6.   

    为什么用了UNION ALL的时候,对查询结果进行修改会报“缺少用于更新或刷新的基本表信息” 的错误。不用的时候没事
      

  7.   

    子查询用一个别名
    s = "select * from (" & _
    "select * from 车辆排班 where instr(车牌,'" & a & "') and 日期 <>null and cdate('" & b & "')>=cdate(操作日期) " & _
    "Union All " & _
    "select * from 车辆排班二 where instr(车牌,'" & a & "') and 日期 <>null and cdate('" & b & "')>=cdate(操作日期)) A " & _
    "order by cdate(A.操作日期) desc "
      

  8.   

    1:
    Union中子句不可用order by可以先union后再排序,如8楼给出的代码,即select * from
    (
    子句1
    union
    子句2
    )
    order by 某字段方法2:可以把子句套子句,如select * from (子句1 order  by 字段)
    union all
    select * from (子句2 order  by 字段)即可