SQL: Using the LIKE Operator

SELECT <column1_name>, <column2_name>,..., <columnx_name>
FROM <table_name>
WHERE <columnN> LIKE pattern;
  1. % : The percent symbol represents zero or more unknown characters.
  2. _ : The underscore symbol represents a single unknown character.
  3. [] : The brackets represent any one character within the brackets.
  4. ^ : The caret symbol, when used within the brackets symbol, represents any one character NOT within the brackets.
  5. - : The dash symbol, when used within the brackets symbol, represents any one character from a range of characters within the brackets.
SELECT first_name, last_name, phone_number
FROM clients_table
WHERE phone_number LIKE pattern
SELECT first_name, last_name, phone_number
FROM clients_table
WHERE phone_number LIKE '(917)%'
SELECT title, author_fname, author_lname
FROM books
WHERE author_fname = 'Malcolm' AND author_lname LIKE '%bach'

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

The 2021 Full Stack Developer Roadmap

Useful Links in Goldfinch

How to root Alcatel One Touch 7040d

ScreenShot_20160422225054

Write An Efficient Auto-complete Program Using Trie

Warehouse62 220v Battery Power Station

Numbering System edge cases of java

Network Plugins In K8 With Calico

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Malcolm Katzenbach

Malcolm Katzenbach

More from Medium

How To Go From SQL Zero to SQL Hero

SQL Hero

The magic power of UNPIVOT in SQL

SQL Server Partitioning : What is it? When to use it? When not to use it?

Create Million Dummy Data Less Than 1 Minute