Forum > Database
[SOLVED] Substrings in ZMSQL
(1/1)
maurobio:
Dear ALL,
Many dialects of SQL (MySQL, SQLite, etc.) have a handy SUBSTR() function which extract a substring from a string (starting at any position), for example:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---SELECT SUBSTR(CustomerName, 2, 5) AS ExtractString FROM Customers;
However, the ZMSQL library (https://wiki.freepascal.org/ZMSQL) offers two rather unusual variations of this function, as follows:
--- Quote ---substr_after(source, substring) Returns the part of source that comes after substring. If substring is not found an empty string is returned.
substr_before(source, substring) Returns the part of source that comes before substring. If substring is not found an empty string is returned.
--- End quote ---
I do not understand how these functions work and have not been able to find any examples. Could some one provides me with a few hints?
Thanks in advance!
With best wishes,
paweld:
mid(expression, from, count) : https://github.com/git-bee/janSQL/blob/master/doc/6_functions.md#64-string-functions
--- Code: SQL [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---SELECT string_col, mid(string_col, 2, 5) FROM TABLE
maurobio:
Dear @paweld,
Thanks a lot, it is now clear and it works fine!
With best wishes,
Navigation
[0] Message Index