where条件: not exists (select '1' from name1 where 输入值的条件判断) and not exists (select '1' from name2 where 输入值的条件判断)
select '1' from name1 where 输入值的条件判断 请问你这样写是不是吧name1当成个表了 但是name1是个字段啊
“与NAME1和NAME2里面的记录”还以为是两个表呢,回贴时没见到你的补充。 NAME1和NAME2是字段的话,它里面的内容就不叫记录,叫字段值了。 条件写成: exists (select '1' from table where 参数A<>name1 and 参数A<>name2) 表中数据多的话,子查询后面加个“and rownum<=1”应该会快点。
exists是碰见第一条满足的记录就返回了,不需要加rownum限制的为什么不写成:exists (select 1 from table where name1 = 参数A or name2 = 参数A)
select‘存在' from dual where exists (select 1 from table where name1 = 参数A or name2 = 参数A)
在表中的NAME1 NAME2字段查询 看这个两个字段的记录中A是否存在额 大概就是这个意思
not exists (select '1' from name1 where 输入值的条件判断) and not exists (select '1' from name2 where 输入值的条件判断)
请问你这样写是不是吧name1当成个表了
但是name1是个字段啊
NAME1和NAME2是字段的话,它里面的内容就不叫记录,叫字段值了。
条件写成: exists (select '1' from table where 参数A<>name1 and 参数A<>name2)
表中数据多的话,子查询后面加个“and rownum<=1”应该会快点。
where
exists (select 1 from table where name1 = 参数A or name2 = 参数A)
以前在DB2中试验过,只取一条和不加限制,SQL的执行时间有差别。