当前位置: 代码迷 >> PB >> 检查表中是否有符合条件的记录数 EXISTS 和 count(),刚才没说清,继续探讨,该怎么处理
  详细解决方案

检查表中是否有符合条件的记录数 EXISTS 和 count(),刚才没说清,继续探讨,该怎么处理

热度:141   发布时间:2016-04-29 09:46:59.0
检查表中是否有符合条件的记录数 EXISTS 和 count(),刚才没说清,继续探讨
oracle 中:

select 'x' from dual where exists( select 'X' from table1 where id = 'S' )

select count(1) from table1 where id = 'S' 

select top 1 col1 from table1 where id = 'S'

哪个效率高呢?

在sybase 中有哪个表相当于 oracle 的 dual ?

------解决方案--------------------
好像都差不多! sybase没用过,应该可以用top 1吧!
------解决方案--------------------
探讨
oracle 中:

select 'x' from dual where exists(  select  'X'  from table1 where  id =  'S'  )

select  count(1)  from table1 where  id =  'S'

select top 1 col1  from table1 where id = 'S'

哪个效率高呢?

在sybase 中有哪个表相当于 oracle 的 dual ?
  相关解决方案