Filter mysql result after certain text (regex)

Web IT
Web IT used Ask the Experts™
on
Note:The table itsels is irrelavent to the question and as such it's not posted. (becuase the query is correct).

My question is :
Is there an SQL way to filter (such as regex) only select (not to update the table just display when queried)
out everything after the pipeline.



1) I only want to display/query not update the query results/
Here is the query result (which is working fine and the output is what should be outputed)   the "pipe " /  "|" delimiter is not another column
I will repeat again so it's not confusing
the "pipe " /  "|" delimiter is not another column it's one string.

3)The query

SELECT meta_value FROM wp_postmeta WHERE meta_key LIKE 'etimeclockwp-in%'

2)  the output (this is one column).
1576486935|8
1576141273|21
1574067745|23

3) Sample output after the questioned query  :
1576486935
1576141273
1574067745

Thank You.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Ryan ChongSoftware Team Lead

Commented:
not quite sure if I understand your requirement but it seems that you want to do a like match within the content of field that contain "|" ?

try provide some sample data and tell us your expected output.

Author

Commented:
I updated my question with the sample  output.
Software Team Lead
Commented:
you can apply function substring_index into your query.

to implement:

SELECT meta_value, substring_index(meta_value, '|', 1) value
FROM wp_postmeta
WHERE meta_key LIKE 'etimeclockwp-in%'

Open in new window


more info:

SUBSTRING_INDEX(str,delim,count)
https://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function_substring-index

Author

Commented:
This query works thank you !
I did see the substring but was having syntax issues.
Thanks alot.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial