SQLsever查询语句
时间: 2023-11-21 10:34:53 浏览: 76
SQL Server 是一种关系型数据库管理系统,支持 SQL 语言。以下是一些常见的查询语句:
1. 选择所有列和行:
SELECT * FROM table_name;
2. 选择特定列和行:
SELECT column1, column2 FROM table_name WHERE condition;
3. 使用排序:
SELECT column1, column2 FROM table_name ORDER BY column1 DESC;
4. 聚合函数:
SELECT COUNT(column1) FROM table_name;
5. 连接表:
SELECT column1, column2 FROM table1 JOIN table2 ON table1.column1 = table2.column1;
6. 使用子查询:
SELECT column1, column2 FROM table_name WHERE column1 IN (SELECT column1 FROM table2 WHERE condition);
7. 分组:
SELECT column1, COUNT(column2) FROM table_name GROUP BY column1;
8. 使用通配符:
SELECT * FROM table_name WHERE column1 LIKE 'abc%';
9. 更新行:
UPDATE table_name SET column1 = value1 WHERE condition;
10. 删除行:
DELETE FROM table_name WHERE condition;
阅读全文