Welcome Guest, Not a member yet? Register   Sign In
Searching with Fname + Lname
#1

[eluser]mexor[/eluser]
I didn't realize it but my search doesn't work correctly. If theres someone named John Candy it will find you if you type in "John" or "Candy" but not if you type in "John Candy".

I'm just using this SQL call:
$query = $this->db->query("SELECT * FROM registered WHERE fname LIKE '%$q%' OR lname LIKE '%$q%' ORDER BY lname ASC");

So clearly it won't get it if the Q is "fname lname" ... How do I get my search to find that too?

-Dave
#2

[eluser]xwero[/eluser]
i'm not sure if it's going to work but you could try

SELECT * FROM registered WHERE CONCAT_WS(' ',fname,lname) LIKE '$q' OR fname LIKE ‘%$q%’ OR lname LIKE ‘%$q%’ ORDER BY lname ASC
#3

[eluser]mexor[/eluser]
nope, that didn't do it... =(
#4

[eluser]xwero[/eluser]
I've just tested it with CONCAT_WS(’ ‘,fname,lname) LIKE ‘$q’ and CONCAT_WS(’ ‘,fname,lname) = ‘$q’ and it found the full name.




Theme © iAndrew 2016 - Forum software by © MyBB