Golang Tutorials - Learn Go Programming with Easy Step-by-Step Guides

Explore comprehensive Golang tutorials for beginners and advanced programmers. Learn Go programming with easy-to-follow, step-by-step guides, examples, and practical tips to master Go language quickly.

How To Use Like In Sql in SQL

How To Use Like In Sql in SQL

How to Use LIKE in SQL

The LIKE operator is used to search for a specified pattern in a column, often with wildcards.


Syntax:

SELECT columnsFROM table_nameWHERE column_name LIKE pattern;

Wildcards used with LIKE:

WildcardMeaningExample
%Matches zero or more characters'Jo%' matches "John", "Joanna"
_Matches exactly one character'J_n' matches "Jan", "Jen"

Examples:

1. Find employees whose name starts with "Jo":

SELECT *FROM employeesWHERE name LIKE 'Jo%';

2. Find employees whose name has "an" in the middle:

SELECT *FROM employeesWHERE name LIKE '%an%';

3. Find employees whose name is 3 characters and starts with "J":

SELECT *FROM employeesWHERE name LIKE 'J__';

Notes:

  • LIKE is case-insensitive in some databases (e.g., MySQL), but case-sensitive in others (e.g., PostgreSQL).

  • To perform case-insensitive search in PostgreSQL, use ILIKE.


If you want examples with escape characters or regex alternatives, just ask!

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql