codesnout.com

SQL LIKE

Google Ads

SQL LIKE


SQL Sample Code - SQL LIKE Operator.

Notes:- Wildcards are used a lot using the LIKE operator. Go to the Wildcards section to learn more

SELECT column_name(s)
FROM table_name
WHERE column_name LIKE pattern;

See the SQL samples section below for an explanation of the LIKE operator


What does the SQL LIKE operator do?

The SQL LIKE operator filters out columns based upon criteria specified with conditions which match a certain pattern.


Sample – SQL LIKE

In this SQL sample we will use the database table ‘tblCompany’.

Company_ID CompanyName Address Town
1 SQL Sample 1 Sample St Hamburg
2 SQL Code Land 2 Code Rd Hamburg
3 Sample Code World 66 SQL St Curry
4 SQL Reference Ltd 34 Reference St Pisa
5 MySQL Code Geeks 5 Sample Ave Humberside

In this SQL sample we want to retrieve all the Columns from the tblCompany table whose company has an Address beginning with ‘H’.

Use the SELECT statement below:

SELECT * FROM tblCompany WHERE Address LIKE ‘H%’;

The table of results will look like this:

Notes:- Wildcards are used a lot using the LIKE operator. Go to the Wildcards section to learn more.

Company_ID CompanyName Address Town
1 SQL Sample 1 Sample St Hamburg
2 SQL Code Land 2 Code Rd Hamburg
5 MySQL Code Geeks 5 Sample Ave Humberside

 


Related SQL Sample Code:


About Us | Privacy Policy | Contact Us | ©2010 Thunderousity Information Management Solutions | www.autosnout.com - Car Performance Statistics Website Utilising SQL | SQL Blog |

SQL Home | SQL Intro | SQL SELECT Statement | DISTINCT | WHERE | SQL Wildcards | AND OR | IN | BETWEEN | LIKE | ORDER BY | GROUP BY | TOP | ALIAS | DELETE | INSERT | UPDATE | CREATE DATABASE | CREATE TABLE | ALTER | INNER JOIN | FULL JOIN | LEFT JOIN | RIGHT JOIN | UNION | CONSTRAINTS | NOT NULL| Aggregate Functions | SUM | AVG | COUNT | MAX | MIN | FIRST | LAST | GROUP BY | HAVING | LIMIT | Microsoft Access Data Types | MySQL Data Types | SQL Server Data Types | ASCII HTML Reference Sheet |