sql

Searching or Like Query in Sql

Like query in SQL can be used to search through one column or multiple columns in a table.

SELECT column_name_1, column_name_2
FROM table_name
WHERE column_name_2 LIKE %q%;

Here are some pattern examples that can be helpful while creating Like query in SQL

LIKE 'w%' - Return rows where column values start with "w"

LIKE '%w' - Return rows where column values  that end with "w"

LIKE '_w%' - Return rows where column values  that have "w" in the second position

LIKE 'w_%' - Return rows where column values  that start with "w" and are at least 2 characters in length

LIKE 'w__%' - Return rows where column values that start with "w" and are at least 3 characters in length

LIKE '%he%' - Return rows where column values  that have "he" in any position

LIKE 'w%e' - Return rows where column values that start with "w" and end with "e"

Was this helpful?