Shawn - You answered the right question. Since a SQL
statement is closer to my grasp right now , today,
trying that approach.
I think this is something close to correct, though I'm
stuck on what to assign to @usrDays:=
SELECT DateEntry from Entry_Table,
WHERE DateEntry >= DATE_SUB(CurDate(), Interval
@usrDays:= <?> day )
I'll continue to bang away , eventually I should get
it.
Stuart
--- SGreen@stripped wrote:
> Stuart,
>
> I feel you pains. I think I can speak for most of us
> to say "we've been
> there, too"
>
> First, You want to try to keep your column values
> on the LEFT side of any
> inequality. MySQL just goes faster that way.
>
> SELECT ....
> WHERE EntryDate >= DATESUB(CurDate(),
> Interval 2 day )
>
> About using a variable for your date value, you have
> two options. First,
> you could just modify your PHP code to stick a
> number into the correct
> place of your SQL statement:
>
> $querystring = "SELECT .... WHERE EntryDate >=
> DATESUB(CurDate(), Interval
> ". $daysdiff ." day )"
>
> Or you can create SQL statement that sets a MySQL
> variable that contains
> the # of days you want to subtract then use that
> variable in your WHERE
> clause. Either way you are combining the value you
> get from the user-entry
> field and using it to create a valid SQL statement.
> Personally, I would
> do the first. (my logic: I don't need the variable
> except to use it in the
> very next statement and if I have to merge values
> and text once, anyway,
> why not just put the correct value into my original
> query)
>
> Please let me know if I answered the wrong question,
> OK?
>
> Shawn Green
> Database Administrator
> Unimin Corporation - Spruce Pine
>
>
>
> Stuart Felenstein <stuart4m@stripped> wrote on
> 09/13/2004 11:54:02 AM:
>
> > Shawn, partially discourage but mostly confused
> about
> > what I really need to do.
> >
> > Bear in mind for a moment, that I'm working in a
> > somewhat untradional manner. Meaning a) very new
> to
> > database and SQL b) (and i realize this list is
> not
> > for programming languages) using a RAD that allows
> me
> > to point, click and insert , where it's magically
> > transformed into code.
> >
> > So back to what I'm trying to accomplish. I want
> a
> > way for the user to be allowed to choose from what
> > point in the timeline records will be returned in
> a
> > search. i.e. from 30 days or less, 15 days or
> less, 2
> > days or less, etc.
> >
> > Now, if I run this query against the
> > entry_table.entry_date_column
> >
> > select EntryDate from EntryTable
> > where Date_Sub(Curdate(), interval 2 day) <=
> EntryDate
> >
> > life is good. I get the records returned just the
> way
> > I want. They key though is the 2 (after interval)
> as
> > I want that number to be a variable.
> >
> > That is why I created the table that has values of
> 1,
> > 2 , 15, 30, etc). I thought if I could use those
> > values, in either a case statement (probably not
> with
> > 4.0.20) or an "if statement" , well magic would
> happen
> > ;)
> >
> > I hope I explained it better this time.
> > Apologies for the confusion.
> > Stuart
> > --- SGreen@stripped wrote:
> >
> > > Were you able to solve you problem another way
> or
> > > just discouraged by my
> > > response? I wasn't trying to make you feel bad,
> you
> > > just covered so much
> > > ground in your original post that I really
> couldn't
> > > understand your issue.
> > > Please, post again but with a little more
> > > background.
> > >
> > > We all want to help but we aren't there looking
> over
> > > your shoulder so we
> > > can't see everything you see. We just need a
> little
> > > help to visualize your
> > > problem, OK?
> > >
> > > Respectfully,
> > >
> > > Shawn Green
> > > Database Administrator
> > > Unimin Corporation - Spruce Pine
> > >
> > > Stuart Felenstein <stuart4m@stripped> wrote on
> > > 09/13/2004 11:09:59 AM:
> > >
> > > > Ok, never mind . I guess a conditional loop
> is
> > > not
> > > > needed.
> > > >
> > > >
> > > > Stuart
> > >
> >
>