由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - 需要帮助 -- Oracle Query
相关主题
请帮我看看,什么地方错了?我也问一个sql querry的问题
请问这两个SQL QUERY有什么错?请教一个query in mysql
Oracle下如何能得到所有table的名字?recursive query help
a complex sql query, high hand help!!!Is there such a thing as "limited writing access" in Oracle database server
如何完成这个sql?问一个转行到数据库方面的事,急求大家建议!
有没有可能将在Access里做好的东西导入到Oracle里去how to write this query
请教一个SQL Query新手请教:为什么这个Query不work
help on this queryQuery help - pivot table
相关话题的讨论汇总
话题: item话题: query话题: incident
进入Database版参与讨论
1 (共1页)
c***c
发帖数: 6234
1
我有两个tables,incidents 和 ConfigurationItems
每个incident都必须有Configuration Item。
但一些Apps把错误的Configuration Item名字放到incident里了。大概400W个incident
,15000个Configuration Items。
我怎么能用最有效的query把所有有无效的Configuration Item incident query 出来
呢?
select incident_id from incidents
where ci_name not in (select ci_name from configurationitems)
怎么return 0 row
有没有更有效的query呢?
谢谢
t********k
发帖数: 808
2
首先你要弄清楚,你的那些错误的Configuration Item在不在表configurationitems里
?如果都在这个表里,你用not in,肯定是找不到数据的
如果说不在表configurationitems里的就是错误的Configuration Item,那你的SQL语
句是对地
select incident_id from incidents
where ci_name not in (select ci_name from configurationitems)
应该可以把你的问题说的再细些
c***c
发帖数: 6234
3
谢谢回复。
那些错误的CI确实不在ci table里。但按你的query,确实返回0 row呀。
我用了笨办法
select i.incident_id, i.ci_name, ci.ci_name
from incidents i, configuration_items ci
where ci.ci_name (+)= i.ci_name
and ci.ci_name is null

【在 t********k 的大作中提到】
: 首先你要弄清楚,你的那些错误的Configuration Item在不在表configurationitems里
: ?如果都在这个表里,你用not in,肯定是找不到数据的
: 如果说不在表configurationitems里的就是错误的Configuration Item,那你的SQL语
: 句是对地
: select incident_id from incidents
: where ci_name not in (select ci_name from configurationitems)
: 应该可以把你的问题说的再细些

1 (共1页)
进入Database版参与讨论
相关主题
Query help - pivot table如何完成这个sql?
这个query怎么写?有没有可能将在Access里做好的东西导入到Oracle里去
Help on Oracle query请教一个SQL Query
oracle和XMLhelp on this query
请帮我看看,什么地方错了?我也问一个sql querry的问题
请问这两个SQL QUERY有什么错?请教一个query in mysql
Oracle下如何能得到所有table的名字?recursive query help
a complex sql query, high hand help!!!Is there such a thing as "limited writing access" in Oracle database server
相关话题的讨论汇总
话题: item话题: query话题: incident