mysql - Select all unique emails inside a column filled with data -
i have column's field filled kinds of data user request (one request per row).
i need email addresses these users' requests, , placed in column according following format:
[...data...] email: mysql@se.com phone: [...remaining data...]
i have found question:
select part of table column data in mysql
which provides solution part of problem:
select substr(message,instr(message,'email: ')+7) user_req_log
however, return unwanted remaining data.
what's efficient way confine results strings need (email addresses) and, @ same time, ignore duplicates?
based on question's solution, may do:
select distinct substr(message, @ini_pos:=instr(message,'email: ')+7, instr(message,' phone:')-@ini_pos) `user_req_log`
it may not efficient way, it's similar:
- use 3 parameters of
substring(str,pos,len)
; - get positions before , after email address through
instr(str,substr)
orlocate(substr,str)
/position(substr in str)
. - assign variable email's initial position (
@ini_pos
) , reuse subtract position know ends; - use
distinct
return each email once.
Comments
Post a Comment