把查询语句赋值给string变量,在吧string赋值给其余重复的部分
把查询语句赋值给string变量,在把string赋值给其余重复的部分,
下面查询有很多字符串重复的部分,
select Id ,Tid as 类型,Title as 标题,Cover as 图片
from Video as A where Tid in
(select Id from VideoType where tid in
(select Id from VideoType where tid in
(select Id from VideoType where tid in
(select Id from VideoType where tid in
(select id from VideoType where tid in(select id from VideoType where Title in('老人专区','幼儿专区')))))))
or Tid in
(select Id from VideoType where tid in
(select Id from VideoType where tid in
(select Id from VideoType where tid in
(select id from VideoType where tid in(select id from VideoType where Title in('老人专区','幼儿专区'))))))
or tid in
(select Id from VideoType where tid in
(select Id from VideoType where tid in
(select id from VideoType where tid in (select id from VideoType where Title in('老人专区','幼儿专区')))))
or tid in
(select Id from VideoType where tid in
(select id from VideoType where tid in (select id from VideoType where Title in('老人专区','幼儿专区'))))
or tid in
(select id from VideoType where tid in (select id from VideoType where Title in('老人专区','幼儿专区')))
or tid in (select id from VideoType where Title in('老人专区','幼儿专区'))
能不能这样 string a=" (select Id from VideoType where tid in"
然后把 a 一个个都接上去,
这样SQL整体就缩小了很多.
select Id ,Tid as 类型,Title as 标题,Cover as 图片
from Video as A where Tid in
a
a
a
a
a(select id from VideoType where Title in('老人专区','幼儿专区')))))))
or Tid in
a
a
a
a(select id from VideoType where Title in('老人专区','幼儿专区'))))))
or tid in
a
a
a (select id from VideoType where Title in('老人专区','幼儿专区')))))
or tid in
a
a (select id from VideoType where Title in('老人专区','幼儿专区'))))
or tid in
a(select id from VideoType where Title in('老人专区','幼儿专区')))
or tid in (select id from VideoType where Title in('老人专区','幼儿专区'))