更新时间:2025-07-18 GMT+08:00
查询数据
本章节主要介绍Doris查询表数据的SQL基本语法和使用说明。
基本语法
SELECT [hint_statement, ...] [ALL | DISTINCT | DISTINCTROW | ALL EXCEPT ( col_name1 [, col_name2, col_name3, ...] )] select_expr [, select_expr ...] [FROM table_references [PARTITION partition_list] [TABLET tabletid_list] [TABLESAMPLE sample_value [ROWS | PERCENT] [REPEATABLE pos_seek]] [WHERE where_condition] [GROUP BY [GROUPING SETS | ROLLUP | CUBE] {col_name | expr | position}] [HAVING where_condition] [ORDER BY {col_name | expr | position} [ASC | DESC], ...] [LIMIT {[offset,] row_count | row_count OFFSET offset}] [INTO OUTFILE 'file_name']
使用示例
- 查询student表中年龄分别为18,20,25的学生姓名:
SELECT Name from student where age in (18,20,25);
- 查询student表中年龄最小的三位学生的姓名,先对age使用order by排序,asc为升序(默认),desc为降序,然后limit显示3条记录:
SELECT Name from student order by age asc limit 3;
父主题: Doris常用SQL命令