A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/postgresql/postgresql-not-like-operator/ below:

PostgreSQL - NOT LIKE operator

PostgreSQL - NOT LIKE operator

Last Updated : 12 Jul, 2025

The PostgreSQL NOT LIKE operator is a powerful tool used in SQL queries to filter out rows that do not match specific patterns. By utilizing this operator, users can eliminate undesired string patterns from their results, enabling more precise data retrieval.

It is particularly beneficial in scenarios where specific naming conventions or formats need to be excluded. In this article, We will learn about the PostgreSQL NOT LIKEOperator by understanding various examples and so on.

PostgreSQL NOT LIKE Operator

Syntax:

SELECT column1, column2, ...
FROM table_name
WHERE column_name NOT LIKE pattern;

Explanation:

Examples of NOT LIKE operator

Example 1:

Let's write an query is to retrieve the first and last names of customers from the customer table whose first names do not start with the letter 'K'.

SELECT
first_name,
last_name
FROM
customer
WHERE
first_name NOT LIKE 'K%';

Output:

Explanation:

Example 2:

Let's write an query is to retrieve the first and last names of customers from the customertable whose first names do not contain the substring "her" at the second position.

SELECT
first_name,
last_name
FROM
customer
WHERE
first_name NOT LIKE '_her%';

Output:

Explanation:

Conclusion

In summary, the NOT LIKE operator in PostgreSQL provides an effective means to refine query results by excluding unwanted patterns. Whether you need to filter out names based on their initial letters or exclude specific substrings, this operator simplifies the process.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4