TRIM: TRIM()- TRIM function in SQL is used to remove specified prefix or suffix from a string.
LTRIM(str): Removes all white spaces from the beginning of the string.
SELECT LTRIM(‘ Sample ‘);
RTRIM(str): Removes all white spaces at the end of the string.
SELECT RTRIM(‘ Sample ‘);
CONCAT*Sometimes it is necessary to combine together (concatenate) the results from several different fields:
SELECT CONCAT(region_name,store_name) FROM Geography
WHERE store_name = ‘Boston’Like:
LIKE is another keyword that is used in the WHERE clause. Basically, LIKE allows you to search based on a pattern rather than specifying exactly what is desired .
SELECT “column_name”
FROM “table_name”
WHERE “column_name” LIKE {PATTERN} ;
*{PATTERN} often consists of wildcards.i.e.
SELECT *
FROM Store_Details
WHERE store_name LIKE ‘%AN%’
Wildcard For LIKE*In SQL, there are two wildcards:
% (percent sign) represents zero, one, or more characters.
_ (underscore) represents exactly one character.
Wildcards are used with the LIKE keyword in SQL.
• ‘A_Z’: All string that starts with ‘A’, another character, and end with ‘Z’. For example, ‘ABCZ’ and ‘A34Z’ would both satisfy the condition, while ‘AKKZ’ would not (because there are two characters between A and Z instead of one).
• ‘ABC%’: All strings that start with ‘ABC’. For example, ‘ABCDE’ and ‘ABABC’ would both satisfy the condition.
• ‘%XYZ’: All strings that end with ‘XYZ’. For example, ‘VWXYZ’ and ‘ZZXYZ’ would both satisfy the condition.
• ‘%AN%’: All strings that contain the pattern ‘AN’ anywhere. For example, ‘LOS ANGELES’ and ‘SAN FRANCISCO’ would both satisfy the condition.
• ‘_AN%’: All strings that contain a character, then ‘AN’, followed by anything else. For example, ‘SAN FRANCISCO’ would satisfy the condition, while ‘LOS ANGELES’ would not satisfy the condition.