sql not like 多条件
时间: 2023-10-31 07:23:51 浏览: 628
可以使用多个 NOT LIKE 条件,以及 AND 或者 OR 连接它们。例如:
SELECT * FROM my_table WHERE column1 NOT LIKE '%abc%' AND column2 NOT LIKE '%def%' OR column3 NOT LIKE '%ghi%';
这个查询会返回满足以下条件的所有行:
- column1 不包含 "abc"
- column2 不包含 "def"
- 或者 column3 不包含 "ghi"
相关问题
oracle sql语法 not like多条件
在 Oracle SQL 中,如果要使用 NOT LIKE 并且有多个条件,可以使用 AND 或 OR 连接多个 NOT LIKE 语句。
例如,要查询所有名称不包含 "a" 或 "b" 的员工,可以使用以下语句:
SELECT * FROM employees WHERE name NOT LIKE '%a%' OR name NOT LIKE '%b%';
另一个例子,查询所有名称不包含 "a" 并且不包含 "b" 的员工,可以使用以下语句:
SELECT * FROM employees WHERE name NOT LIKE '%a%' AND name NOT LIKE '%b%';
请注意,在这两个例子中,在查询中使用了 %
符号,它是用来做模糊查询的。
sql notlike
SQL中的NOT LIKE是一种条件操作符,用于在WHERE子句中筛选不匹配指定模式的行。 NOT LIKE操作符与LIKE操作符的功能相反。通常情况下,LIKE操作符用于匹配指定模式的行,而NOT LIKE操作符用于匹配不匹配指定模式的行。
使用NOT LIKE操作符时,需要指定一个字符串模式,该模式可包含以下特殊字符:
- % 表示零个或多个字符
- _ 表示一个字符
例如: SELECT * FROM mytable WHERE name NOT LIKE 'J%'; 这个查询将返回名字不以J开头的所有行。
相关推荐
















