The Data Management Center

SQL LIKE


Google
 
Web infogoal.com
HOME | SQL OVERVIEW | SQL BASICS | SQL ADMINISTRATION | SQL ADVANCED | SQL SYNTAX


SQL Book Picks

SQL Cookbook
SQL Cookbook by Anthony Molinaro


SQL Visual Quick Start
SQL: Visual QuickStart Guide (2nd Edition) by Chris Fehily

SQL Bible
SQL Bible by Alex Kriegel, Boris M. Trukhnov

SQL Complete Reference
SQL: The Complete Reference, Second Edition by James R Groff, Paul N. Weinberg

SQL for Smarties
Joe Celko's SQL for Smarties: Advanced SQL Programming Third Edition by Joe Celko

Murach SQL Server
Murach's SQL for SQL Server by Bryan Syverson

Previous | Next

SQL > SQL Advanced > SQL LIKE


What is SQL LIKE?

The SQL LIKE operator enables a comparison to a part of a string using the % wild card character.

Why Use SQL LIKE?

The SQL LIKE operator is a powerful way to check for matching strings. It is often used for interactive display of lists.

How To Use SQL LIKE

SQL LIKE is used as follows.

SQL LIKE Syntax

 
SELECT <column_list>
FROM <table_name>
WHERE <column_name> LIKE <like_condition>
 

The <like_condition> supports the following patterns:

  • 'ABC%' - where a string begins with the letters 'ABC'
  • '%XYZ' - where a string ends with the 'XYZ'
  • '%TUV%' - where the string contais 'TUV' anywhere

SQL LIKE Example

The following example lists rows from the branch table where branch_name begins with the leading characters 'San'.

Here are the contents of the table:

Table: BRANCH
branch_nbrbranch_nameregion_nbremployee_count
108New York10010
110Boston1006
212Chicago2005
404San Diego4006
415San Jose4003

This SQL Statement with LIKE is executed:

 
SELECT branch_nbr, branch_name, employee_count
FROM branch
WHERE branch_name LIKE 'San%'
 

Here is the result.

branch_nbrbranch_nameemployee_count
404San Diego6
415San Jose3

infogoal.com HOME
SQL OVERVIEW

SQL BASICS
SQL SELECT
SQL WHERE
SQL INSERT
SQL UPDATE
SQL DELETE

SQL ADMINISTRATION
SQL CREATE DATABASE
SQL DROP DATABASE
SQL CREATE TABLE
SQL ALTER TABLE
SQL DROP TABLE
SQL CREATE INDEX
SQL DROP INDEX
SQL ADD FOREIGN KEY
SQL DROP FOREIGN KEY
SQL CREATE VIEW
SQL DROP VIEW

SQL ADVANCED
SQL CONCAT
SQL SUBSTRING
SQL TRIM
SQL AND & OR
SQL IN
SQL BETWEEN
SQL LIKE
SQL DISTINCT
SQL GROUP BY
SQL AGGREGATE
SQL HAVING
SQL ORDER BY
SQL JOIN
SQL OUTER JOIN

SQL SYNTAX

Data Model Resource Book Vol 1
Data Model Resource Book Vol 2
HOME | SQL OVERVIEW | SQL BASICS | SQL ADMINISTRATION | SQL ADVANCED | SQL SYNTAX
Copyright© 1999-2006, First Place Software, Inc.