Heim  >  Artikel  >  Backend-Entwicklung  >  在视图中使用ORDER BY子句_PHP教程

在视图中使用ORDER BY子句_PHP教程

WBOY
WBOYOriginal
2016-07-13 17:03:38819Durchsuche

问:为什么SQL Server不允许在视图定义使用ORDER BY子句?
答: SQL Server之所以不允许在视图定义中使用ORDER BY子句是为了遵守ANSI SQL-92标准。因为对该标准的原理分析需要对结构化查询语言(SQL)的底层结构和它所基于的数学理论进行讨论,我们不能在这里对它进行充分的解释。但是,如果你需要在视图中指定ORDER BY子句,可以考虑使用以下方法:
USE pubs
GO
CREATE VIEW AuthorsByName
AS
SELECT TOP 100 PERCENT *
FROM authors
ORDER BY au_lname, au_fname
GO
Microsoft在SQL Server 7.0中引入的TOP结构在同ORDER BY子句结合使用时是非常有用的。只有在同TOP关键词结合使用时,SQL Server才支持在视图中使用ORDER BY子句。
 
注意:TOP关键词是SQL Server对ANSI SQL-92标准的扩展。
 


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/630957.htmlTechArticle问:为什么SQL Server不允许在视图定义使用ORDER BY子句? 答: SQL Server之所以不允许在视图定义中使用ORDER BY子句是为了遵守ANSI SQL-92标准。因...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn