searching data using sql query

I have a simple sql query where I am trying to allow my employees to have the ability to search for other employees in my db. I want them to be able to search by both, or either first/last name. I have this, but it’s not working.

 var selectEmployee = "select * from employees where UPPER(FIRSTNAME, LASTNAME) LIKE UPPER('%" + req.body.search + "%')" 

so how would I search through both first and last name using the req.body.search value I am passing back?

thanks.

17 thoughts on “searching data using sql query”

  1. Use OR

    var selectEmployee = "select * from employees where FIRSTNAME LIKE '%" + req.body.search + "%' OR LASTNAME LIKE '%" + req.body.search + "%'"
    

    you may use UPPER function

    Reply

Leave a Comment