SQL Server 2016 表操作:查询表记录

  • 查询语法
SELECT select_list FROM table_source;
  • DISTINCT 对查询结果集进行去重
SELECT DISTINCT select_list FROM table_source;
  • TOP 查询表中前 n 行数据
SELECT TOP 行数 select_list FROM table_source;

示例演示

-- 查询表中所有结果
SELECT * FROM Student;

-- 查询 name
SELECT name FROM Student;

-- 查询去重后的 name
SELECT DISTINCT name FROM Student;

-- 查询前 3 条数据
SELECT TOP 3 * FROM Student;

《SQL Server 2016 表操作:查询表记录》 image.png
《SQL Server 2016 表操作:查询表记录》 image.png
《SQL Server 2016 表操作:查询表记录》 image.png
《SQL Server 2016 表操作:查询表记录》 image.png

    原文作者:CursiveS
    原文地址: https://www.jianshu.com/p/55da5200e3be
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞