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

Friday, 23 February 2024

position Function in MARIADB

In MariaDB, the POSITION function is used to find the position of a substring within a string. It is similar to the LOCATE function in MySQL. The POSITION function returns an integer value representing the position of the first occurrence of the substring within the string. If the substring is not found, it returns 0.


Here's the syntax of the POSITION function in MariaDB:


POSITION(substring IN string)

- substring: The substring to search for within the string.

- string: The string in which to search for the substring.


Example:

SELECT POSITION('world' IN 'hello world') AS position;


This will return 7, indicating that the substring 'world' starts at the 7th position within the string 'hello world'.

No comments:

Post a Comment

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