mysql - Match single input and two database fields -


i'm building search form website, single input fields (name , lastname) , need match against 2 database fields (name_field , lname_field). users can type in name first or lastname (or lastname) prefer. thank you

assuming user inputs null when not used:

select *     yourtable     name_field = coalesce(@name, name_field)         , lname_field = coalesce(@lastname, lname_field) 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -