由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - Late afternoon 腦不好使
相关主题
怎么reference temp table的column[转载] Can anyone interpret this simple SQL?
怎么求和急,SQL2005, 怎么查过去一小时里run过的所有query?
[Mysql] how to return NULL count in group by query (转载)请教怎么来log duration of a MYSQL procedure?
请问这个update query有什么问题?如何在数据库中进行复杂查询, 但不把中间结果放到程序内存
A sql questionJob openings with Teradata (zt)
[转载] 求教数据库的query optimization 工作的面试今典问题: 这个Self Query咋写?
请问个join的问题SP is less performance than Direct SQL Query if using CTE?
how to make query faster?请问如何实现这样一个db2的query, 谢谢
相关话题的讨论汇总
话题: query话题: blah话题: select话题: method话题: temptable
进入Database版参与讨论
1 (共1页)
i****a
发帖数: 36252
1
SQL 2005
I need to write 2 queries:
Query 1, blah blah blah
Query 2, I need to hit the rows that are NOT in Query 1
Method A:
Query 1, select blah into #temptable where blah = 1
Query 2, select blah not in (select blah from #temptable)
Method B:
Query 1, select blah where blah = 1
Query 2, select bah not in (select blah where blah = 1)
which one is more efficient? Is query optimize gonna make method B more
efficient? Is the only way to know to see query plan?
i****a
发帖数: 36252
2
Method A:
Query 1
UNION
Query 2
Error: The SELECT INTO statement cannot have same source and destination
tables.
sigh...
i****a
发帖数: 36252
3
seems like CTE works
;with CTE_blah
(
select blah where blah = 1
)
select * from CTE_blah
union
select blah not in (select blah from CTE_blah)
1 (共1页)
进入Database版参与讨论
相关主题
请问如何实现这样一个db2的query, 谢谢A sql question
向大牛请教 query问题啊![转载] 求教数据库的query optimization 工作的面试
MATCH,MATCH,MATCH请问个join的问题
最近写了不少SQL script,请大牛评价下属于什么水平how to make query faster?
怎么reference temp table的column[转载] Can anyone interpret this simple SQL?
怎么求和急,SQL2005, 怎么查过去一小时里run过的所有query?
[Mysql] how to return NULL count in group by query (转载)请教怎么来log duration of a MYSQL procedure?
请问这个update query有什么问题?如何在数据库中进行复杂查询, 但不把中间结果放到程序内存
相关话题的讨论汇总
话题: query话题: blah话题: select话题: method话题: temptable