Skip to content

pattern-matching-functions-in-PostgreSQL #318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
-- The Like operator

SELECT *
FROM Student
WHERE name LIKE 'John%';

SELECT *
FROM Student
WHERE name LIKE 'P____p%';

-- The ILike operator

SELECT *
FROM Student
WHERE name ILIKE '%rob%';

SELECT *
FROM Student
WHERE name ILIKE 's%' AND gpa > 3.5;

-- The similar to operator

SELECT *
FROM Student
WHERE name SIMILAR TO '[JRP]%y';

SELECT *
FROM Student
WHERE birth_date::TEXT SIMILAR TO '200[0-2]-%';

-- POSIX Regular Expressions

-- The ~ and ~* Operators

SELECT *
FROM Student
WHERE name ~ '^R.*a$';

SELECT *
FROM Student
WHERE name ~* 'Bert';

-- The !~ and !~* Operators

SELECT *
FROM Student
WHERE enrollment_date::TEXT !~ '^2020';

SELECT *
FROM Student
WHERE gpa::TEXT !~* '^[4-5]\.';