本文介绍了多列子选择等效于sql server 2005的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 谁能告诉我如何在sql server中执行此操作? 我目前正在oracle中执行此查询: select table1.col1,table1 .col2,table2.col3,table4.col4 其中table1.col1 = table2.col3和 table2.col3 = table4.col5和 (table1.col1,table1.col2)不在 select table2.col4,table2col5 from table2 它是来自任何一行的两列值不是在table2中的任何 行中发现我无法弄清楚。 谢谢 Jeff 解决方案 行构造函数是ANSI Stanard的一部分,但未在 SQL Server中实现。所以只有在那里为甲骨文填写一个。 幸运的是,在这种情况下你也可以使用NOT EXISTS: 选择... 来自table1 t1 哪里不存在(选择* from table2 t2 其中t1.col1 = t2.col1 和t1.col2 = t2.col2) - Erland Sommarskog, SQL Server MVP, es****@sommarskog.se 联机丛书SQL Server 2005 http: //www.microsoft.com/technet/pro...ads/books.mspx SQL Server 2000联机丛书 http://www.microsoft.com/sql/prodinf...ons/books.mspx 它可以采用略有不同的方式, select table1.col1,table1.col2,table2.col3,table4.col4 其中table1.col1 = table2.col3和 table2.col3 = table4.col5和 cast(table1 as varchar(20))+'' - ''+ cast(col1 as varchar(20))not in( select cast(table2.col4 as varchar (20))+'' - ''+演员(表2 .col5 as varchar(20))来自table2) 问候 Monojit 行构造函数是ANSI Stanard的一部分,但未在SQL Server中实现。因此,只有在那里为Oracle填写一个。 幸运的是,在这种情况下你也可以使用NOT EXISTS: select。 .. 来自table1 t1 哪里不存在(从表2中选择* t2 其中t1.col1 = t2.col1 和t1.col2 = t2.col2) 非常感谢。我会测试一下。 Jeff Can anyone tell me how to do this in sql server?I am currently doing this query in oracle: select table1.col1,table1.col2,table2.col3,table4.col4where table1.col1 = table2.col3 andtable2.col3 = table4.col5 and(table1.col1,table1.col2) not inselect table2.col4,table2.col5 from table2it is the where two column values from any row are not found in anyrow in table2 part that I can''t figure out. thanksJeff 解决方案 Row constructors is part of the ANSI Stanard, but not implemented inSQL Server. So it''s only to chalk one up for Oracle there. Fortunately, in this situation you could just as well use NOT EXISTS: select ...from table1 t1where not exists (select *from table2 t2where t1.col1 = t2.col1and t1.col2 = t2.col2) --Erland Sommarskog, SQL Server MVP, es****@sommarskog.se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspxBooks Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx It can be done slightly different way,select table1.col1,table1.col2,table2.col3,table4.col4where table1.col1 = table2.col3 andtable2.col3 = table4.col5 andcast(table1 as varchar(20)) +''-''+cast(col1 as varchar(20)) not in(select cast(table2.col4 as varchar(20)) + ''-'' + cast(table2.col5 asvarchar(20)) from table2) RegardsMonojit Row constructors is part of the ANSI Stanard, but not implemented inSQL Server. So it''s only to chalk one up for Oracle there.Fortunately, in this situation you could just as well use NOT EXISTS:select ...from table1 t1where not exists (select * from table2 t2 where t1.col1 = t2.col1 and t1.col2 = t2.col2)thanks much. I''ll test things out.Jeff 这篇关于多列子选择等效于sql server 2005的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-19 06:52