hi to all
i have three fields of name in database named as fnam,mname,lnam e. fname and lname is mandatory field and mname is optional.
i want to make a search query on name
in records where mname is not empty then above code is working properly but records in which mname is empty then i have to enter double space between fname and lname which disturb search
on the other case when i write
in records where mname is empty then above code is working properly but records in which mname is not empty then i have to remove space between fname and lname which disturb search
please provide me some solution. can i use if condition in concat?
i need to know if i am not clear in my question
i have three fields of name in database named as fnam,mname,lnam e. fname and lname is mandatory field and mname is optional.
i want to make a search query on name
Code:
mysql_query("SELECT * FROM abc where CONCAT(fname,' ',mname,' ',lname) like'" . $q . "%' order by id");
on the other case when i write
Code:
mysql_query("SELECT * FROM abc where CONCAT(fname,' ',mname,'',lname) like'" . $q . "%' order by id");
please provide me some solution. can i use if condition in concat?
i need to know if i am not clear in my question
Comment