I'm trying to make a search by different option say A, B . what i need is if user provide value of A only then it does the searching using parameter A only , if user provide A and B then it needs to do searching using condition A=value1 AND B=value2. How can i do this please help how can i start?

6 Years
Discussion Span
Last Post by 47pirates

That almost looks like the pseudo-code for the solution...
user provide value of A only then search using A==value1
if user provide A and B then search using A==value1 && B==value2.

Where exactly arer you getting stuck?


there are 5 fields in my program name, address, number, salary ,post i need to do the searching as for A,B,C provided A+B+C for A , D provided condition should be A+D. how many query state ment do i have to write?


You couild use a wild-card approach, eg set all 4 search values to "*" then replace any/all with the value(s) given by the user, then write a single if test that goes like

`if ( (value1.equals("*") || (value1.equals(A))  && 
      (value2.equals("*") || (value2.equals(B)) ... etc`
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.