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?

Recommended Answers

All 4 Replies

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`

:) thanks job done!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.