I have an array (arr) with n elements, n = 1 or 2, and a table in database called employees that contains two fields (name and surname)
I want to perform the following query using Eloquent (and, possibly, some kind of iteration ?), in order to implement an "instant search" functionality:
select * from employees
where (name LIKE '%arr[0]%' AND surname LIKE '%arr[1]%')
OR
where (name LIKE '%arr[1]%' AND surname LIKE '%arr[0]%')
Any help appreciated
Thank you
EDIT: To state my question more clearly, in case there is only one element in the arr I would like to perform the following query:
select * from employees
where (name LIKE '%arr[0]%' AND surname LIKE '%arr[0]%')
that is, to look for the given arr element in either name or surname fields.
Aucun commentaire:
Enregistrer un commentaire