Hardwarez Posted November 2, 2007 Share Posted November 2, 2007 I have a table with 5 names fields in it. I want to search all 5 for a name. This is what I have tried: $query = "SELECT * FROM timesheets WHERE name1 LIKE '%$semployee%'"; Finds single names fine $query = "SELECT * FROM timesheets WHERE name1 OR name2 LIKE '%$semployee%'"; Only fines one of many. Ie finds Jane Doe, but does not find Jane $query = "SELECT * FROM timesheets WHERE name1 OR name2 OR name3 OR name4 OR name5 LIKE '%$semployee%'"; This one takes a long time to run and returns nothing like the name I entered. How can I do the search to get LIKE names in any on of my 5 name entries in my table? ??? Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 2, 2007 Share Posted November 2, 2007 you have to specify the match again $query = "SELECT * FROM timesheets WHERE name1 LIKE '%$semployee%' OR name2 LIKE '%$semployee%'"; Quote Link to comment Share on other sites More sharing options...
fenway Posted November 2, 2007 Share Posted November 2, 2007 Or you could fulltext all 5 columns... but I question the duplication of columns, goes against normalization rules. Quote Link to comment Share on other sites More sharing options...
Hardwarez Posted November 2, 2007 Author Share Posted November 2, 2007 Thank you! Its been a while for me.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.