473,796 Members | 2,677 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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
Nov 17 '06 #1
8 2542

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

Nov 17 '06 #2
"strawberry " <za*******@gmai l.comwrote:
>
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
Nov 17 '06 #3
"strawberry " <za*******@gmai l.comwrote:
>
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
Nov 17 '06 #4

Keith wrote:
"strawberry " <za*******@gmai l.comwrote:

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?

Nov 17 '06 #5
> I created a query like this: "SELECT * FROM tablename WHERE 'updated'
> '$startstring' ORDER BY 'updated'"
Note that this query does not reference the updated field at all,
except for the "select *" part.
>// $startstring holds the date-time string exactly like the 'updated'
field should look.
'updated' is a string, not a field name.
>In the much more efficient WHERE clause it does not work.

Where am i going wrong?
`updated` is a field name. 'updated' is a string.
Nov 18 '06 #6
"strawberry " <za*******@gmai l.comwrote:
>
Keith wrote:
"strawberry " <za*******@gmai l.comwrote:
>
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?
SELECT * FROM tablename HAVING 'updated' '2006-11-16 23:25:22' ORDER
by 'updated'
returns all records from the database not only those updated after
2006-11-16 23:25:22

Nov 18 '06 #7
go***********@b urditt.org (Gordon Burditt) wrote:
I created a query like this: "SELECT * FROM tablename WHERE 'updated'
'$startstring' ORDER BY 'updated'"

Note that this query does not reference the updated field at all,
except for the "select *" part.
// $startstring holds the date-time string exactly like the 'updated'
field should look.

'updated' is a string, not a field name.
In the much more efficient WHERE clause it does not work.

Where am i going wrong?

`updated` is a field name. 'updated' is a string.
Wow, never saw that those back-ticks were so important, I always used
normal ticks and it worked, but not now.

THANK YOU
Nov 18 '06 #8
Keith wrote:
go***********@b urditt.org (Gordon Burditt) wrote:

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

Note that this query does not reference the updated field at all,
except for the "select *" part.

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

'updated' is a string, not a field name.

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

Where am i going wrong?

`updated` is a field name. 'updated' is a string.

Wow, never saw that those back-ticks were so important, I always used
normal ticks and it worked, but not now.

THANK YOU
if updated is a column name then the query should look like:

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

Depending on your datefield you may need to "convert" the time to something the
database can actually use.

It is always a good idea to test your select statements interactively before
moving it to your applciation.
--
Michael Austin.
DBA Consultant
Nov 19 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4155
by: rdraider | last post by:
I am looking for some assistance with an update query that needs to link 3 tables: This query ran and reported over 230,000 records affected but did not change the field I wanted changed, not sure what it did. I did notice that the "name" in "GM_NAMES.name" was colored blue in Query Analyzer. Is it bad to name a column "name"? UPDATE ABSENCES set CustomerContactID = cicntp.cnt_id
15
1870
by: James | last post by:
Hello Everyone! I'm trying to design a database for a library that stocks a range of media. (see link) http://homepage.ntlworld.com/james.merrie/private/library.gif Each user can make many enquiries / reservations / loans (if I can get enquiries right, I can do the rest). Every Enquiry can be made on each item of stock, every item of stock is
3
4037
by: Neil Hindry | last post by:
I wonder if you can help me. I have setup an address-book database in Access XP. I have the first name & surname as separate fields. As I wanted to sort my database by surname and then by first name I had surname before first name when I created the fields of my database.. To do the sort (in table view) I highlighted the two columns (fields), in this case surname and first name, and selected sort. Access then sorted the database by...
3
4569
by: Jim Archer | last post by:
Hi All... I'm been fighting this problem for a few days now, and it seems like it should be simple. But the solution has eluded me so far... I need to flag a record when it is updated or when it is a new insert. Then I SELECT for the changed records and do something not related to Postgres. Easy enough, I created a trigger procedure and fired it on INSERT OR UPDATE and modify NEW to set the flag field to true.
7
1484
by: phillip.s.powell | last post by:
Now I have another SQL query for MySQL I can't figure out!! This is overwhelming me completely and I also must have this figured out today and I can't figure it out!! UPDATE student_db.student SET has_letter1 = ( SELECT i.letter1 FROM olddb.student i, student_db student s WHERE s.unique_key = i.unique_key )
1
1550
by: rdraider | last post by:
Hi all, I know squat about triggers so was hoping somebody could point me in the right direction. I wanted to copy an email address field from a salesman table to a note field in a customer table. Seems easy enough for a one time update. But I would like to add a trigger to auto-update the customer table anytime an email address changes in the saleman table or a new salesman record is added. Here's my update script (this copies the...
23
2808
by: casper christensen | last post by:
Hi I run a directory, where programs are listed based on the number of clicks they have recieved. The program with most clicks are placed on top and so on. Now I would like people to be apple to place a link on there site so people can vote for their program, "ad a click". eg someone clicks the link on some page and it counts +1 click on my page. if some one clicks the link below it will count a click on my page.
0
1702
by: jon | last post by:
Hi there, I'm brand new to Access and may be trying to do too much too soon, but I wanted to get some expert advice on how the best way to go about what I am trying to accomplish would be. I am trying to modify the Microsoft Template at the following address (http://office.microsoft.com/en-us/templates/TC012186931033.aspx?CategoryID=CT101426031033) to work as an issues tracker that imports and updates the issues from a SQL 2005...
8
1970
by: 08butoryr | last post by:
Hey guys I could really use your help with some very basic java programming. I know you programming fundis out there will find this child's play but I'm struggling with it a bit because I'm realtively new at programming.The topic is "Using a database and SQL". The exercise supplies a table called tblStudent in a database called School and requires you to perform certain actions with the table. Here are the requirements that I am having problems...
4
1581
by: Paul David Buchan | last post by:
Hello, I'm attempting to write a program to read in database files (.dbf). When I do it all as a single procedure in main, everything works. However, what I really want, is to pass the database filename to a function, and have it pass back an array containing the database contents, and some parameters telling me the dimensions of the array. I've succeeded in getting my function to read in the dbf file, and it returns the dimensions of...
0
9684
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9530
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10236
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10182
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10017
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7552
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6793
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5577
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4120
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.