like
clause in PostgreSQLThe like
clause is used in PostgreSQL to compare and match wildcards and see if a matching pattern exists. If a pattern exists, the output is 1
(true
).
like
There are situations in which we remember the first or last letter of a word but cannot remember the exact word. Like
comes to the rescue in such situations.
Like
can be used in various situations such as:
The wildcards used with the
Like
Operator are%
and_
.
WHERE kind:: text LIKE %table
: To search any text that ends with table.
WHERE kind:: text LIKE table%
: To search any text that starts with table.
WHERE kind:: text LIKE %table%
: To search any text with table anywhere in the text.
WHERE kind:: text LIKE %table
: To search any text that starts with table.
WHERE kind:: text LIKE _table%
: To search any text with table starting from the second position and any letters after the table.
limit
clause in PostgreSQLThe limit
clause is not used very often. limit
is used with the SELECT
statement when the table has a large amount of data and we want to restrict
the output.
SELECT rowName
FROM tablename
LIMIT count
We can set a count with the limit to specify the number of rows to be displayed.
If the count is 0
, then no rows are displayed.
If the count is NULL
, all the rows are displayed, just like a simple SELECT
statement.
SELECT thriller
FROM movies
LIMIT 5
The above example will display 5
rows from the movies table that are thrillers.
RELATED TAGS
CONTRIBUTOR
View all Courses