Stuart.

If your queries must match _all_ of your input variables, you are in the 
situation where you only need ANDs (no ORs needed).  Just create one term 
in your WHERE statement for each field they filled in and make sure  that 
there is an AND between each of them in the right places.  This should be 
a piece of simple string building along the same lines you are already 
doing. 

I think that the reason that nobody, including myself, can tell you how to 
write your script is because you never told us _your_ rules on how each 
field is supposed to be handled.  Build your WHERE clause so that it meets 
_your_  requirements and it should work correctly. 

Of course, no input from the user means you don't need a WHERE clause at 
all. You can regurgitate your entire database. This may be something you 
want to avoid by requiring at least 1 or 2 input values.

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine

Stuart Felenstein <[EMAIL PROTECTED]> wrote on 09/22/2004 03:11:16 PM:

> The returned values should be exact. As far as how
> much data, I'm assuming your talking about amount of
> records ?
> Potentially eventually maybe quite a bit.
> Currently mysql statement is comprised of select and
> from with all the proper joins.
> But I"m confused, when you say below actual SQL call
> here, is the referring to the SQL statement that would
> look at all the imput values and process the data ?
> like a series of and's or or's  ?
> 
> Stuart
> --- gerald_clark <[EMAIL PROTECTED]>
> wrote:
> 
> > Depending on how exact the returned values need to
> > be, and how much data 
> > you have to
> > sift through, you could do. ( perl example )
> > $job=$dbh->quote($job.'%');
> > $city=$dbh->quote($city.'%');
> > $start=$dbh->quote($start.'%");
> > .
> > .
> > .
> > 
> > $select = "SELECT * from myfile where jobtitle like
> > $job and  city like 
> > $city and start like $start and industry like
> > $industry and state like 
> > $state and taxterm like $taxterm";
> > .
> > .
> > do the actual SQL call here. 
> > 
> > Stuart Felenstein wrote:
> > 
> > >I'm back, trying to figure my way through a
> > somewhat
> > >confusing set of conditons.
> > >Sort of doing a sanity check here.
> > >First explanation:
> > >I've put together a search (the database) form that
> > >has 6 inputs.
> > >Just to clarify, the fields are 
> > >1-JobTitle
> > >2-City
> > >3-Start
> > >4-Industry
> > >5-State
> > >6-TaxTerm.
> > >
> > >The idea is that a user can choose one , two or all
> > >fields to put criteria into.  Regardless, whichever
> > >one they choose , there should be a records return.
> > 
> > >More criteria of course adds more refinement.
> > > 
> > >
> > 
> > 
> > 
> 
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
> 

Reply via email to