Tutorials

SQL Clause and Operator


SQL LIKE


Syntax for LIKE

SELECT * FROM table_name
WHERE column LIKE pattern;

Example on LIKE

We will use tih_Courses table for demonstration purpose

tih_Courses
Course_ID Course_Name Professor Mode_of_Training
001 .Net Mukesh Tiwari Online and Offline
002 Java Rajneesh Shukla Online and Offline
003 ANSI SQL Rajneesh Shukla Online
004 Basics of Computer Shweta  Online
005 Blogging Tutorial Puja  Online
006 JSP Alok Pandey Online and Offline
007 Servlet Mukesh Tiwari Online and Offline

Query-1: Write sql query to select all rows where course name has 'sql' in it.

SELECT * 
FROM tih_Courses 
WHERE Course_Name LIKE '%sql%';

On executing the above query succesfully, we get:

tih_Courses
Course_ID Course_Name Professor Mode_of_Training
003 ANSI SQL Rajneesh Shukla Online

Query-2: Write sql query to select all rows where course name starts with 'B' in it.

SELECT * 
FROM tih_Courses 
WHERE Course_Name LIKE 'b%';

On executing the above query succesfully, we get:

tih_Courses
Course_ID Course_Name Professor Mode_of_Training
004 Basics of Computer Shweta  Online
005 Blogging Tutorial Puja  Online

 



Please Share this page
Views : 69
Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!