select * from user t
where
t.userId = 1
and t.age > (select b.age from b b where b.id = #id#)
如果红色语句查询是 null 最下面的条件就不需要 了 怎么写
where
t.userId = 1
and t.age > (select b.age from b b where b.id = #id#)
如果红色语句查询是 null 最下面的条件就不需要 了 怎么写
解决方案 »
- 表里有格式如'2012-03-01 00:00:00'这样的时间字段,想以某个月份month 作为查询条件,来查询这一个月的数据,sql应该怎么写?
- ORA-01033: ORACLE initialization or shutdown in progress
- 【ORA-24777 不可使用不可移植的数据库链路】
- 求一SQL语句.........................................标题要长
- 问一个表中某个字段的排序问题
- 批量数据插入的问题
- oracle动态行转列
- 前辈指点(~§~)
- ORA-00933: SQL 命令未正确结束???
- 复制用户权限问题,急,急,急!在线等,分不够再加
- 数据更新语句求助
- sqluldr2导出oracle数据,参数field问题
select * from user t
where
t.userId = 1
and t.age > case when (select b.age from b b where b.id = #id#) is null then 0
else
(select b.age from b b where b.id = #id#)
end
where
t.userId = 1
and
( t.age > (select b.age from b b where b.id = #id#) or
0=(select nvl(max(b.age),0) from b where b.id = #id#))
FROM USER t, (SELECT b.age FROM b b WHERE b.id = #id#) d
WHERE t.userId = 1
AND t.age > nvl(d.age, t.age - 1)
SELECT *
FROM USER t, (SELECT max(b.age) age FROM b b WHERE b.id = #id#) d
WHERE t.userId = 1
AND t.age > nvl(d.age, t.age - 1)