Answer the question
In order to leave comments, you need to log in
How to set a MAC address lookup pattern in SQL?
In the Tickets table, the text is written in free form in the Comment field. Among other things, MAC addresses are written in free form in this text. It is necessary to find all lines containing the wanted MAC.
Text examples:
Купили роутер f8f02804213e оплата нал
Замена роутера по гарантии. Старый 28:28:00:42:11:AA новый AA:BB:CC:55:66:77
Установлен пон D345.00ff.41ED
Купили ротер 28:28:00:55:66:77
%28%28%00%55%66%77%
finds not only 4 examples, but also 2. Answer the question
In order to leave comments, you need to log in
SELECT * FROM tickets
WHERE UPPER( REPLACE( REPLACE( REPLACE( text, '.', '' ), ':', '' ), '-', '' )) LIKE '%282800556677%'
falling under a condition something like "serial number 1F2828004211AA0065400121"In such cases, the delimiter is used:
SELECT * FROM tickets
WHERE CONCAT(' ', UPPER( REPLACE( REPLACE( REPLACE( text, '.', '' ), ':', '' ), '-', '' )) , ' ')
LIKE '% 282800556677 %'
SELECT * FROM tickets t WHERE t.text REGEXP '([0-9A-Fa-f]{2}[.:-]?){5}([0-9A-Fa-f]{2})'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question