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
Post a Comment