Click here to get back home

Help wanted - Struggling with 'updated'-NOW() field

 HomeNewsGroups | Search | About
 mailing.database.mysql    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Help wanted - Struggling with 'updated'-NOW() field Keith 11-17-2006
Get Chitika Premium
Posted by Keith on November 17, 2006, 10:19 am
Please log in for more thread options
I try to learn SQL by figuring out things.

I want to make a listing of all records that were changed in the
last... 1, 6, 12 hours/days.

I have a field called 'updated' managed like: UPDATE tablename SET
updated = NOW(), .... WHERE....

I created a query like this: "SELECT * FROM tablename WHERE 'updated'
> '$startstring' ORDER BY 'updated'"

// $startstring holds the date-time string exactly like the 'updated'
field should look.

When in php i do: if($record[updated] > $startstring) ..show record..;
it works, but then I must pull the entire database.

In the much more efficient WHERE clause it does not work.

Where am i going wrong?
--
/Kees

Posted by strawberry on November 17, 2006, 3:15 pm
Please log in for more thread options

Keith wrote:

> I try to learn SQL by figuring out things.
>
> I want to make a listing of all records that were changed in the
> last... 1, 6, 12 hours/days.
>
> I have a field called 'updated' managed like: UPDATE tablename SET
> updated = NOW(), .... WHERE....
>
> I created a query like this: "SELECT * FROM tablename WHERE 'updated'
> > '$startstring' ORDER BY 'updated'"
>
> // $startstring holds the date-time string exactly like the 'updated'
> field should look.
>
> When in php i do: if($record[updated] > $startstring) ..show record..;
> it works, but then I must pull the entire database.
>
> In the much more efficient WHERE clause it does not work.
>
> Where am i going wrong?
> --
> /Kees

try echoing the query


Posted by Keith on November 17, 2006, 5:29 pm
Please log in for more thread options

>
> Keith wrote:
>
> > I try to learn SQL by figuring out things.
> >
> > I want to make a listing of all records that were changed in the
> > last... 1, 6, 12 hours/days.
> >
> > I have a field called 'updated' managed like: UPDATE tablename SET
> > updated = NOW(), .... WHERE....
> >
> > I created a query like this: "SELECT * FROM tablename WHERE 'updated'
> > > '$startstring' ORDER BY 'updated'"
> >
> > // $startstring holds the date-time string exactly like the 'updated'
> > field should look.
> >
> > When in php i do: if($record[updated] > $startstring) ..show record..;
> > it works, but then I must pull the entire database.
> >
> > In the much more efficient WHERE clause it does not work.
> >
> > Where am i going wrong?
> > --
> > /Kees
>
> try echoing the query

Sorry its standard testing for me, but that shows exactly what i want
it to show:

SELECT * FROM tablename HAVING 'updated' > '2006-11-16 23:25:22' ORDER
by 'updated'

--
/Keith

Posted by Keith on November 17, 2006, 5:35 pm
Please log in for more thread options

>
> Keith wrote:
>
> > I try to learn SQL by figuring out things.
> >
> > I want to make a listing of all records that were changed in the
> > last... 1, 6, 12 hours/days.
> >
> > I have a field called 'updated' managed like: UPDATE tablename SET
> > updated = NOW(), .... WHERE....
> >
> > I created a query like this: "SELECT * FROM tablename WHERE 'updated'
> > > '$startstring' ORDER BY 'updated'"
> >
> > // $startstring holds the date-time string exactly like the 'updated'
> > field should look.
> >
> > When in php i do: if($record[updated] > $startstring) ..show record..;
> > it works, but then I must pull the entire database.
> >
> > In the much more efficient WHERE clause it does not work.
> >
> > Where am i going wrong?
> > --
> > /Kees
>
> try echoing the query

Just realise: it does work, but it does not select so te whole
database is pulled, so the WHERE clause does not do it's job.
--
/Keith

Posted by strawberry on November 17, 2006, 7:13 pm
Please log in for more thread options

Keith wrote:
>
> >
> > Keith wrote:
> >
> > > I try to learn SQL by figuring out things.
> > >
> > > I want to make a listing of all records that were changed in the
> > > last... 1, 6, 12 hours/days.
> > >
> > > I have a field called 'updated' managed like: UPDATE tablename SET
> > > updated = NOW(), .... WHERE....
> > >
> > > I created a query like this: "SELECT * FROM tablename WHERE 'updated'
> > > > '$startstring' ORDER BY 'updated'"
> > >
> > > // $startstring holds the date-time string exactly like the 'updated'
> > > field should look.
> > >
> > > When in php i do: if($record[updated] > $startstring) ..show record..;
> > > it works, but then I must pull the entire database.
> > >
> > > In the much more efficient WHERE clause it does not work.
> > >
> > > Where am i going wrong?
> > > --
> > > /Kees
> >
> > try echoing the query
>
> Just realise: it does work, but it does not select so te whole
> database is pulled, so the WHERE clause does not do it's job.
> --
> /Keith

eh?


Similar ThreadsPosted
Extracting Field data and putting each field into a shell variable? June 19, 2006, 3:28 pm
SETting a datetime field based on a text field September 29, 2006, 5:42 pm
I want field data without field name, how? July 19, 2006, 10:50 am
Field to textfield April 20, 2006, 3:43 am
Field to textfield April 20, 2006, 3:50 am
fetching one field August 21, 2006, 4:53 am
INSERT: pad out timestamp field June 3, 2005, 12:57 am
Blank Date Field September 12, 2005, 1:41 pm
Offset to geometry field February 3, 2006, 8:48 am
Checking a field for NULL February 13, 2006, 3:05 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap