select distinct(a.f_id),a.* ,case f_opr_type when 0 then c.f_title when 1 then d.f_title when 2 then e.f_title end as title from M_USRLOG a,M_RAWLUT c, M_PROD d,M_DISPATCH e where (a.f_cnt_id = c.f_id and a.f_opr_type=0) or (a.f_cnt_id = d.f_id and a.f_opr_type=1) or (a.f_cnt_id = e.f_id and a.f_opr_type=2) or (a.f_opr_type=3)
(由f_opr_type 对应不同表的f_title) 是不是复杂了,有没有简化的,这比子查询效率高吧? 另外一个问题是, 当c,d,e表中没有记录时不能正确工作,有什么解决办法?数据库不熟,半桶水.谢谢!
(由f_opr_type 对应不同表的f_title) 是不是复杂了,有没有简化的,这比子查询效率高吧? 另外一个问题是, 当c,d,e表中没有记录时不能正确工作,有什么解决办法?数据库不熟,半桶水.谢谢!
解决方案 »
- delphi 中ado EnableBCD已设为false,但数据小数超过4位的问题 如0.0000001
- delphi 中 vclzip 如何加密文件名
- 关于运算
- 请问这是什么原因造成的错误啊?在访问数据库提交时报的错!
- 欢迎光临!!!!
- 打印机输出问题(在线等待,紧急)?
- 求一个字段(a8)的和,并将其存入一个变量中,用SQL语句写,请教!
- 怎样将在已画图形上再次画其它图形,而不会出现重叠现象?
- 我机器经常死机,我估计哪个木马在做怪,我如何判断我机器存在木马
- 普通数据库系统能通过 odbc 或 bde 指定数据源, 现在我用 ado 如果不通过 odbc 有什么办法在安装时指定数据源?(好像通过odbc 会降低效 )
- 深圳朋友,请进......
- 什么情况下,建立一个抽象类?
from M_USRLOG a,M_RAWLUT c
where a.f_cnt_id = c.f_id and a.f_opr_type=0
union
select a.f_id,a.* ,d.f_title as title
from M_USRLOG a,M_PROD d,M_DISPATCH e
where a.f_cnt_id = d.f_id and a.f_opr_type=1
union
select a.f_id,a.* ,e.f_title as title
from M_USRLOG a,M_DISPATCH e
where a.f_cnt_id = e.f_id and a.f_opr_type=2不知道搂住的a.f_opr_type=3 是干什么用的
休息以下,看看电影吧,呵呵,免费的午餐!!