This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

search programming

 
Azeem Rathore
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello my first language is German so bear with my English
I am new to java language , and working on Human resource Management system , current i cant make logic of search programming , actually i want to search the employees by their personal info
so i have 5 text box
Employee Name:
Employee mobile no:
Employee Father Name:
Employee Social Security Number
Employee Address:

these are the text boxes now i want to search from employee table. All information of employees are in one table which is called Tbl_Employees.
now i am confused how to do it ? Requirement is Any field can be empty it is not necessary all 5 boxes should contain values
so kindly tell me how to handle this if a user only give social security number and rest all fields are empty then what to do ? if user fill two or more textbox then what should i do ?
any tutorial/article related to this will be helpful please
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you need to construct a SQL query that uses exactly those fields where the user has entered something. You could start by writing SQL queries (directly, not as part of Java code) that do those searches for a single field, maybe "name". Then write another one for "father name". Then combine those into a single query that would be run if the user entered something into both fields.
 
Azeem Rathore
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok thanks i am some how able to manage this as it is only one table now

i have one other functionality to perform which is whole software internal search if a user just enter any text in text box . and it search it from whole application?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you still asking about searching that one DB table? What would a SQL query look like that searches all 5 fields even if there is just a single entry field?

If you're talking about searching more tables, or other text (like documents), I'd put a solution using Lucene in place.
 
Azeem Rathore
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is how i am handling 5 text field search

first it checks if all the textbox contain values then just get the values and make sql


2: Rule of thumb is atleast one textfield value should be given if there is empty textfield leave those textfields and those who contain values pick up those values and make sql statement

After this programming my next task is to do full internal site search , i have checked Lucene and download it documentation from apache lucene website i will consider it this

Thanks alot for the help .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic