This topic has been archived. It cannot be replied.
-
工作学习 / 专业技术讨论 / 关于SQL的小问题, 请DX指教, 看看那个STATEMENT最有效,有个PRODUCT TABLE有PRODNUM栏位, 有个DEPARTMENT表,放PRODUCT属于哪个DEPARTMENT, 现在要找出有那些PRODUCT没有属于DEPARTMENT,不知道哪个SQL STATMENT可以很快的找出来?谢谢
-liulang(流浪);
2005-9-1
{4}
(#2481498@0)
-
select * from Product where poductnum not in (select product from Department)
-open(-close);
2005-9-1
(#2481539@0)
-
This is a good answer for SQL-Server, but not for Oracle, etc.
-wonderlife(Wonderlife);
2005-9-1
(#2482102@0)
-
bad answer for SQL server as well...
-schen(睹往睹来);
2005-9-1
{623}
(#2482203@0)
-
Good point. 但楼主不必介意我和schen的讨论,尽管用open的答案即可。
-wonderlife(Wonderlife);
2005-9-1
(#2482328@0)
-
to be honest, i didnot think about perfermance issue at all, i assume the poster only need a answer, he may be a student, (this question is petty like school assignment).i just want to give some basic idea.
-open(-close);
2005-9-1
{36}
(#2482398@0)
-
select * from product where not exists ( select * from departemnt where department.product=product.productnum)
-findinghouse(不写错别字。1);
2005-9-1
(#2482417@0)
-
select DISTINCT * from product where not exists ( select * from departemnt where department.product=product.productnum)
-open(-close);
2005-9-1
(#2482440@0)