Search query in mysql -


i have problem need solution: in db have codes in format:

xxxx xxx  

when users search codes in mode result ok when user search xxxxxxx no results. use query

select * data data '%$search%' 

any suggestions?

as research, have understood search codes fixed size. following sql query may work. because tested sample data.

select * data data  concat("%",trim(substring('xxxx xxx',1,4))," ",trim(substring('xxxx xxx' 5)),"%")  select * data data  concat("%",trim(substring('xxxxxxx',1,4))," ",trim(substring('xxxxxxx' 5)),"%") 

this actual query tested.

then query follows, either

select * data data  concat("%",trim(substring('$search',1,4))," ",trim(substring('$search' 5)),"%") 

or

select * data data  concat("%",trim(substring($search,1,4))," ",trim(substring($search 5)),"%") 

test may result.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -