0

I have the below query;

SELECT * FROM `` WHERE `fname` LIKE 'argument' OR `lname` LIKE 'argument'

What do I need to change in order to 'concatenate' the columns so that I can search for rows LIKE fname.lname ?

0

1 Answer 1

5

Perhaps you want to concatenate the fields together for the like:

SELECT *
FROM staff 
WHERE concat_ws(' ', fname, lname) LIKE '%".$searchq."%';

If the comparison could go either way, then you might want two comparisons:

SELECT *
FROM staff 
WHERE concat_ws(' ', fname, lname) LIKE '%".$searchq."%' or
      concat_ws(' ', lname, fname) LIKE '%".$searchq."%'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.