sql sever like语句
时间: 2023-10-31 20:43:26 浏览: 78
1. SELECT * FROM table_name WHERE column_name LIKE '%search_term%'
2. SELECT * FROM table_name WHERE column_name LIKE 'search_term%'
3. SELECT * FROM table_name WHERE column_name LIKE '%search_term'
4. SELECT * FROM table_name WHERE column_name LIKE '[abc]%'
5. SELECT * FROM table_name WHERE column_name LIKE '[^abc]%'
6. SELECT * FROM table_name WHERE column_name LIKE '_bc%'
7. SELECT * FROM table_name WHERE column_name LIKE '%bc_'
8. SELECT * FROM table_name WHERE column_name LIKE 'a%e'
9. SELECT * FROM table_name WHERE column_name LIKE 'a%%e'
10. SELECT * FROM table_name WHERE column_name LIKE 'a%e%'
相关问题
sqlsever的like语句
SQL Server 中的 LIKE 语句用于筛选符合指定模式的数据。它使用通配符来匹配字符串。
基本语法如下:
```sql
SELECT column1, column2, ...
FROM table_name
WHERE columnN LIKE pattern;
```
其中,`columnN` 是要匹配的列名,`pattern` 是用来匹配的模式。模式中可以使用以下通配符:
- `%` 表示任意字符出现任意次数(包括零次)。
- `_` 表示任意单个字符。
例如,要筛选出名字中以 "J" 开头的员工,可以使用以下语句:
```sql
SELECT * FROM employees
WHERE name LIKE 'J%';
```
要筛选出名字中第二个字符为 "o" 的员工,可以使用以下语句:
```sql
SELECT * FROM employees
WHERE name LIKE '_o%';
```
还可以在模式中使用多个通配符,例如:
```sql
SELECT * FROM employees
WHERE name LIKE 'J%n_s';
```
这个模式表示名字以 "J" 开头,以 "n" 结尾,并且第二个字符为任意字符,第四个字符为 "s"。
SQLsever查询语句
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;
阅读全文