As we know Search in Sql can be implemente using 'Like' clause using '%' and '_' operators. This is the simple way to implement search query. For Example,
- SELECT column_name(s) FROM table_name WHERE column_name LIKE pattern;
This query will be ok when we already know what data we need accordingly. But suppose in situation where we don't know how many fields will be searched by the user. For example for the below table we have 6 input fields for the keyword to search by employee id, employee name, employee designation, employee salary, employee role, employee department and we dont know what will be the fields that user will search for, he may be search by id, by name or id and name both or maybe all fields. For this situation we will write the query below,
| Employee id | Employee Name | Employee Designation | Employee Salary | Employee Role | Employee Department |
| 1 | emp_1 | backend developer | 15,000 | development | it |
| 2 | emp_2 | junior php developer | 8,000 | development | it |
| 3 | emp_3 | web designer | 20,000 | designing | it |
| 4 | emp_4 | asp developer | 18,000 | development | it |
| 5 | emp_5 | java deveolper | 30,000 | development | it |
| 6 | emp_6 | senior php developer | 45,000 | development | it |
| 7 | emp_7 | wordpress developer | 9,000 | development | it |
| 8 | emp_8 | project manager | 50,000 | management | it |

Join the conversation! Your thoughts help the community grow.