select c.claimflag ,b.code,c.cname,a.keydat,a.enddat from posdcasinf a,posdchgitm b ,posroprcod c"
+ " where a.orgid =? and a.polnum=? and b.orgid = a.orgid and b.polnum = a.polnum and b.sernum = a.sernum and"
+ " c.orgid = b.orgid and c.operationcode = b.code and c.claimflag='Y'
我现在遇到这个sql,如果我要拆分开这个三表联查,orgid和polnum,sernum,operationcode ,code都是是索引,我应该怎么去实现
直接三表联合就好了,别放在for循环去查。会被骂
能一次查就尽量一次查,然后去优化这个SQL,尽量避免在循环里去执行SQL,这样执行一次SQL就需要跟数据库做一次IO操作,这个是最费时的。