Hi
I am developing a WEB PhoneBook Catalogue for a comany intranet in
JSP & MSACCESS.In this we can add employee information by following attributes:-empl Id,first Name,lastName,department,site,designation,extension,mob no,email Id.So there will be a USER database in which all these fileds will be present & employeeId will be the primary key.
We can search the employee info as follows-
These are the attributes by which I need to make search:
empl Id,first Name,lastName,department,site,designation & for each of this there will be a textbox in my JSP.
So if the user puts only firstName (eg.John)in the textbox & enetrs Search then all the employess with name John in the entire database will be displayed.
If the user enters firstName(eg.John) & Department(eg.HR) then all John in HR department will be displayed.
Like this depending on the values enetered by the user,dnamically databse will be searched.
Now my question is how can I write a single SQL query for this.my query will be something like this:-"select * from user where emplId='"+s1+"' AND firstName='"+s2+"' AND lastName='"+s3+"' AND department='"+s=4+"'....so on
& s1,s2,s3...will be the strings which are taken from databse as the values enetred by the user.
But the problem is if user only enters firstName i.e. "s1" then all other Strings "s2","s3"...will be null & so in the query null value will be passed.
So can anyone help me how to write a dynamic SQL query for where clause for MSACCESS so that I don need to hardcode SQL queries for differnet combination of user Input???