Welcome to plsql4all.blogspot.com SQL, MYSQL, ORACLE, TERADATA, MONGODB, MARIADB, GREENPLUM, DB2, POSTGRESQL.

Friday, 16 February 2024

LOWER Function in PostgreSQL

In PostgreSQL, the LOWER() function is used to convert a string to lowercase. Here's the syntax:

LOWER(string)

Where string is the string expression that you want to convert to lowercase.

Here's an example of using the LOWER() function in PostgreSQL:

Suppose you have a table named employees with a column named first_name, and you want to retrieve all the first names in lowercase:

SELECT LOWER(first_name) AS lower_first_name

FROM employees;

This query will return all the first names from the employees table in lowercase.

You can also use the LOWER() function in combination with other SQL statements. For example, to filter records based on lowercase comparisons:

SELECT *

FROM employees

WHERE LOWER(first_name) = 'john';

This query will retrieve all records from the employees table where the first_name is 'John', 'JOHN', 'john', etc., because the comparison is case-insensitive after converting the first_name to lowercase using the LOWER() function.

No comments:

Post a Comment

Please provide your feedback in the comments section above. Please don't forget to follow.