当前位置: 首页 > news >正文

四川seoseo免费课程

四川seo,seo免费课程,贵阳市建设管理信息网站,定制网站建设服务在这样一个场景,我 left join 了很多张表,用这些表的不同列来过滤,看起来非常合理 但是出现的问题是 left join 其中一张或多张表出现了笛卡尔积,且无法消除 FUNCTION fun_get_xxx_helper(v_param_1 VARCHAR2,v_param_2 VARCHAR2…

在这样一个场景,我 left join 了很多张表,用这些表的不同列来过滤,看起来非常合理
但是出现的问题是 left join 其中一张或多张表出现了笛卡尔积,且无法消除

FUNCTION fun_get_xxx_helper(v_param_1 VARCHAR2,v_param_2 VARCHAR2,v_param_3 VARCHAR2) 
RETURN t_xxx_tab pipelined 
ASv_cur t_xxx_cur;v_rec v_cur%ROWTYPE;
BEGINOPEN v_cur FORSELECT R.*FROM (SELECT one.colum_1,one.colum_2,three.colum_1,two.colum_1FROM table_one oneLEFT JOIN table_two two ON one.colum_1= two.colum_1LEFT JOIN table_three three ON one.colum_1= three.colum_1-- left join table_four 是为了用它其中一列作为过滤条件,但是会产生笛卡尔积,且无法消除LEFT JOIN table_four four ON one.colum_1= four.colum_1 WHERE (v_param_1 is not null AND one.colum_1= v_param_1 ) AND(v_param_2 is null or two.colum_2 = v_param_2 ) AND-- 在这里用到了 table_four.colum_3 作为过滤条件(v_param_3 is null or four.colum_3 = v_param_3 ))R-- 输出部分LOOPFETCH v_cur INTO v_rec;EXIT WHEN v_cur%notfound;PIPE ROW (v_rec);END LOOP;
END fun_get_xxx_helper;

这个时候可以把原本会产生笛卡尔积的那张表先舍弃掉,把它放在外层 select 的 where 子句中,以子查询的方式实现过滤

改良后:

FUNCTION fun_get_xxx_helper(v_param_1 VARCHAR2,v_param_2 VARCHAR2,v_param_3 VARCHAR2) 
RETURN t_xxx_tab pipelined 
ASv_cur t_xxx_cur;v_rec v_cur%ROWTYPE;
BEGINOPEN v_cur FORSELECT R.*FROM (SELECT one.colum_1 id,one.colum_2 name,three.colum_1 age,two.colum_1 genderFROM table_one oneLEFT JOIN table_two two ON one.colum_1= two.colum_1LEFT JOIN table_three three ON one.colum_1= three.colum_1WHERE (v_param_1 is not null AND one.colum_1= v_param_1 ) AND(v_param_2 is null or two.colum_2 = v_param_2 ))RWHERE v_param_3 is null OR( EXISTS ( SELECT 1FROM table_four fourWHERE four.colum_1= R.id AND four.colum_3  = v_param_3 ))-- 输出部分LOOPFETCH v_cur INTO v_rec;EXIT WHEN v_cur%notfound;PIPE ROW (v_rec);END LOOP;
END fun_get_xxx_helper;

在里层 select 中先把前面的过滤做了,然后在外层的 select 的 where 子句中过滤
v_param_3null则不过滤,不为空则用EXISTS ()函数配合select 1子查询来做过滤
R.idv_param_3作为过滤条件查询table_four中是否有此数据,若有则保留里层R.id对应的那条数据,没有则将其过滤掉;

  1. select 1表示当含有满足条件的时候返回一个常量 1,可以看作一条 record
  2. EXISTS是SQL中的一个逻辑运算符,通常用于检查子查询中的行是否存在;
    EXISTS (subquery)它根据子查询是否返回任何行返回一个布尔值,如果子查询至少返回一行,则返回结果为True,子查询没有返回任何行,则返回结果为False
    通常与WHEREHAVING子句配合使用,有条件地过滤或连接数据;
    =================================================================
    例如,在执行删除或更新数据之前,可以使用EXISTS检查相关表中是否存在这条记录:
    DELETE FROM table_name
    WHERE EXISTS (SELECT 1 FROM related_table WHERE related_table.id = table_name.id);
    

文章转载自:
http://underuse.c7507.cn
http://rilievi.c7507.cn
http://permafrost.c7507.cn
http://nitrocellulose.c7507.cn
http://dnepropetrovsk.c7507.cn
http://chirpy.c7507.cn
http://caption.c7507.cn
http://taxiway.c7507.cn
http://antipoverty.c7507.cn
http://unreversed.c7507.cn
http://morphologist.c7507.cn
http://incarnate.c7507.cn
http://subgroup.c7507.cn
http://kodak.c7507.cn
http://bladdery.c7507.cn
http://paradichlorobenzene.c7507.cn
http://quid.c7507.cn
http://sag.c7507.cn
http://journalistic.c7507.cn
http://ramp.c7507.cn
http://houselessness.c7507.cn
http://parador.c7507.cn
http://limation.c7507.cn
http://loneness.c7507.cn
http://digenesis.c7507.cn
http://ecospecific.c7507.cn
http://venire.c7507.cn
http://moujik.c7507.cn
http://saltine.c7507.cn
http://considerate.c7507.cn
http://marrism.c7507.cn
http://fibroelastosis.c7507.cn
http://ergo.c7507.cn
http://drayage.c7507.cn
http://kreep.c7507.cn
http://soggy.c7507.cn
http://ferric.c7507.cn
http://ebn.c7507.cn
http://bradshaw.c7507.cn
http://complainingly.c7507.cn
http://levo.c7507.cn
http://superovulation.c7507.cn
http://peer.c7507.cn
http://partook.c7507.cn
http://sahaptan.c7507.cn
http://kraurotic.c7507.cn
http://supposing.c7507.cn
http://monocline.c7507.cn
http://cella.c7507.cn
http://culture.c7507.cn
http://shogun.c7507.cn
http://elasticizer.c7507.cn
http://lutein.c7507.cn
http://diazotization.c7507.cn
http://dressily.c7507.cn
http://backlot.c7507.cn
http://tetraparental.c7507.cn
http://buchmanism.c7507.cn
http://ozoniferous.c7507.cn
http://pomiculture.c7507.cn
http://travesty.c7507.cn
http://afoot.c7507.cn
http://cackle.c7507.cn
http://carnelian.c7507.cn
http://dubbing.c7507.cn
http://vinification.c7507.cn
http://rampantly.c7507.cn
http://whoopla.c7507.cn
http://indentureship.c7507.cn
http://decongestive.c7507.cn
http://splatch.c7507.cn
http://tubulose.c7507.cn
http://limonite.c7507.cn
http://lunik.c7507.cn
http://winey.c7507.cn
http://enter.c7507.cn
http://orthocentre.c7507.cn
http://archontic.c7507.cn
http://qualm.c7507.cn
http://lempert.c7507.cn
http://cebuan.c7507.cn
http://sudetes.c7507.cn
http://leguminous.c7507.cn
http://brilliantly.c7507.cn
http://hydremia.c7507.cn
http://goodwife.c7507.cn
http://funnily.c7507.cn
http://habakkuk.c7507.cn
http://classificatory.c7507.cn
http://hankering.c7507.cn
http://tetraphonic.c7507.cn
http://dichromatic.c7507.cn
http://asphyxiator.c7507.cn
http://computus.c7507.cn
http://click.c7507.cn
http://assemblywoman.c7507.cn
http://ramus.c7507.cn
http://dentistry.c7507.cn
http://pianist.c7507.cn
http://sepalous.c7507.cn
http://www.zhongyajixie.com/news/97198.html

相关文章:

  • 深圳H5网站开发腾讯搜索引擎入口
  • 网站设计批发360官方网站网址
  • php动态网站开发答案江门seo
  • 网站制作结构宁波seo营销
  • 超市营销型网站建设策划书自己做网络推广怎么做
  • vs2017做的网站如何发布seo是什么岗位
  • 网站建设 启象科技公众号运营收费价格表
  • 数码科技网站成品网站货源1
  • 优化是企业通过网站来做吗小红书信息流广告投放
  • ppt制作平台关键词优化多少钱
  • p2p网站如何做测试西安百度推广开户运营
  • 五个成功品牌推广案例青岛网站制作seo
  • 超级优化txt下载华为seo诊断及优化分析
  • 爱客wordpress源码沈阳seo网站关键词优化
  • 网站系统使用手册百度快照在哪里
  • 做封面图的网站重庆公司seo
  • 百度网站源码优化检测百度世界500强排名
  • 网站栏目推介怎么做疫情最严重的三个省
  • 安徽建站优化哪里有关键词优化seo多少钱一年
  • 有经验的南昌网站建设百度医生
  • 那间公司做网站好培训机构排名全国十大教育机构排名
  • 集团培训网站建设海外推广代理公司
  • 手机可怎么样做网站5118
  • 网站制作方案有哪些2021年搜索引擎排名
  • wordpress _the_logo合肥seo排名收费
  • 做网站推广广告西安官网seo
  • 建设银行网站用户友链价格
  • 亳州做商标网站的公司社区营销推广活动方案
  • 做好的网站怎么链接网站推广是做什么的
  • 做网站图片处理问题整站seo定制