Developing By Me

Project Development and Design

LIKE Condition

LIKE Condition

LIKE is used to search a field for a specific literal value. The most common usage for LIKE is to search a text block for a specific string of characters. This can be done by adding the % sign where the unknown content would be located. If it is applied to the beginning of a value such as ‘%abcd’ then the result will be any field that ends in the string ‘abcd’. If the % is at the end like ‘abcd%’ then the returned field will start with the string of ‘abcd’. Finally the % could be placed on either side like ‘%abcd%’ which means that any field that contains ‘abcd’ anywhere will be returned.

 

Operator SQL Syntax Description
LIKE field1 LIKE ‘abcd’ This LIKE statement is identical to the = statement above
LIKE field1 LIKE ‘abcd%’ This LIKE statement will return any string value that starts with ‘abcd’
LIKE field1 LIKE ‘%abcd’ This LIKE statement will return any string value that ends with ‘abcd’
LIKE field1 LIKE ‘%abcd%’ This LIKE statement will return any string value that contains with ‘abcd’

 

%d bloggers like this: