select distinct qstId,writeDate,infoId,(select realName from dbo.users where id = t.person )person,
(select productCategoryName from dbo.productCategory
where productCategoryId in
(select categoryId
from dbo.product
where productId in (select t2.productId from dbo.quesProductRelation t2 where t2.quesId = t.qstId)
)) categoryId,
((select productName from dbo.product
where productId in
(select t1.productId from dbo.quesProductRelation t1 where t1.quesId = t. qstId))) productId,version,
(select statusName from dbo.productStatus where statusId=t.productStatus)productStatus,
(select bigName from dbo.bigDetail where bigId=t.questionBigCategory) questionBigCategory,
(select smallName from dbo.smallDetail where smallId=t.questionSmallCategory) questionSmallCategory,questionDesc,result,reason,deal,
(select descript from dbo.importDetail where importId=t.import)import,proce,dealer,measure,dealDate,
(select descText from dbo.isCloseDetail where isCloseId=t.isClose)isClose,re
from dbo.question_data t , dbo.productCategory t2,dbo.product t3,dbo.quesProductRelation t4
--where t.qstId = t4.quesId and t4.productId = 9 --根据选择产品查询
where t.qstId = t4.quesId and t4.productId = t3.productId and t3.categoryId = 2--按照产品类别或科室查询
order by qstId desc这个是个查询语句,现在主要问题,有很多个条件,作为where 后面的字句,条件可选可不选。涉及到问题表 question_data ,产品表 包括productId ,[productName],[categoryId]
而类别表是 [productCategoryId],[productCategoryName]
还有一个是问题产品关联表 quesProductRelation 包括[id],[quesId],[productId] 字段假如我在条件选择中,选择 了 按照类别查询。不知where 后面怎么写。还有麻烦给优化下。感觉特别慢
(select productCategoryName from dbo.productCategory
where productCategoryId in
(select categoryId
from dbo.product
where productId in (select t2.productId from dbo.quesProductRelation t2 where t2.quesId = t.qstId)
)) categoryId,
((select productName from dbo.product
where productId in
(select t1.productId from dbo.quesProductRelation t1 where t1.quesId = t. qstId))) productId,version,
(select statusName from dbo.productStatus where statusId=t.productStatus)productStatus,
(select bigName from dbo.bigDetail where bigId=t.questionBigCategory) questionBigCategory,
(select smallName from dbo.smallDetail where smallId=t.questionSmallCategory) questionSmallCategory,questionDesc,result,reason,deal,
(select descript from dbo.importDetail where importId=t.import)import,proce,dealer,measure,dealDate,
(select descText from dbo.isCloseDetail where isCloseId=t.isClose)isClose,re
from dbo.question_data t , dbo.productCategory t2,dbo.product t3,dbo.quesProductRelation t4
--where t.qstId = t4.quesId and t4.productId = 9 --根据选择产品查询
where t.qstId = t4.quesId and t4.productId = t3.productId and t3.categoryId = 2--按照产品类别或科室查询
order by qstId desc这个是个查询语句,现在主要问题,有很多个条件,作为where 后面的字句,条件可选可不选。涉及到问题表 question_data ,产品表 包括productId ,[productName],[categoryId]
而类别表是 [productCategoryId],[productCategoryName]
还有一个是问题产品关联表 quesProductRelation 包括[id],[quesId],[productId] 字段假如我在条件选择中,选择 了 按照类别查询。不知where 后面怎么写。还有麻烦给优化下。感觉特别慢
解决方案 »
- 查询语句,单引号双引号问题?
- .net 上传问题
- 必须有form标记??
- 请问 datagrid 如何实现 单元格的内容 超过 单元格单行 的宽度时 将 单元格超出的内容 用 "..." 显示 ???? 急!!!!!!!
- 怎样使用guid生成一串12位的数字,急,在线===========================================
- VSS的奇怪问题
- 如何添加这个引用
- 一个小问题,在.cs编码时如何调出系统调色板呢?
- 代码如何写呢?
- 项目在数据库连接串可以使用windows帐户、密码吗?
- 纠结~,怎么样才能方便的去掉货币符号?
- 自己的网站调用土豆网的视频会惹来版权等麻烦事吗?
然后用命令执行。
declare @sql varchar(400)
set @sql =
'update t_abc'+
'set olstates=''L1000'',updater='''+@useId+''',updatedate=getdate(),confirmman='''+@useId+''' '+
',isConfirm=''1'' , confirmDate=getdate()'+
' where olno IN ( '+@olno +' ) and olstates in (''L0002'',''L0003'',''L0004'') '
exec(@sql)