PDA

View Full Version : Using LIKE to search


tomyknoker
07-23-2007, 08:30 AM
Hi all... I have been using the following to search:

WHERE FirstName LIKE '%$firstName%'
AND LastName LIKE '%$lastName%'
AND Email LIKE '%$email%'
AND EmployerLocationName LIKE '%$venue%'
AND State LIKE '%$state%'
AND MemberApproved LIKE '%$status%'
AND tblmanager.mngNBR LIKE '%$mng%'

It has been working well but the only thing I realised with the mngNBR, if the user selects say 'Joe Bloggs' and in the database he is number '2', it also outputs all the results of other managers who have number '2'... so Matt Smith '22', John Smith '24'... I'm assuming this is because I have used like but is there any other way I can do it?

guelphdad
07-23-2007, 02:20 PM
no it wouldn't do that, because you are using AND all the other conditions would also have to match and since those first and last names don't match, those other rows would not be returned.

If they are then you are only showing us part of your query or a different one altogether. I'll take a guess and say there is an OR condition somewhere that you've left out here.