MySQL joins columns before matching with LIKE

I have two columns in my database that I want to combine before matching them using instructions LIKE.

My table:

|---------------------------------|
|   ID     |   PREFIX  |  SUFFIX  |
|---------------------------------|
|   1      |     31    |   523    |
|---------------------------------|
|   2      |     62    |   364    |
|---------------------------------|

I want to be able to supply 315and ID 1. Is there an easy way to do this? Right now, I am splitting the search string and matching individual columns.

Thanks.

+4
source share
1 answer
SELECT * FROM table WHERE CONCAT(PREFIX, SUFFIX) LIKE '%315%'
+5
source

Source: https://habr.com/ru/post/1608502/


All Articles