473,382 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

SQL query question

How do I tell an update query to only search the records that are older then
the current record?

I need to figure out how to write a query that will take a record, look to
see if any record with an older date and time has the same address, then
marks a yes/no box to YES if it does not find a duplicate.

I know this can be done, I just don't know how.

I know it will take a subquery of some kind. I am just lost. Any help would
be very much appreciated!
Nov 13 '05 #1
4 1861
Forgot to mention, This is in Access 2000.

Trey wrote:
How do I tell an update query to only search the records that are
older then the current record?

I need to figure out how to write a query that will take a record,
look to see if any record with an older date and time has the same
address, then marks a yes/no box to YES if it does not find a
duplicate.

I know this can be done, I just don't know how.

I know it will take a subquery of some kind. I am just lost. Any help
would be very much appreciated!

Nov 13 '05 #2
"Trey" <tr***********@hotmail.com> wrote in message
news:Sv*****************@twister.socal.rr.com...
How do I tell an update query to only search the records that are older then the current record?

I need to figure out how to write a query that will take a record, look to see if any record with an older date and time has the same address, then
marks a yes/no box to YES if it does not find a duplicate.

I know this can be done, I just don't know how.

I know it will take a subquery of some kind. I am just lost. Any help would be very much appreciated!

Normally it would take a subquery - unfortunately that doesn't work in Jet.
You need to use domain aggregate functions or "queries-feeding-queries".
Give us some more info and someone will be able to write the sql for you.
Nov 13 '05 #3
try in "Record Created" fleld run the query like "[date <*]" and Is Not
Null
try

if NO ........ then
txtFledName = yes in VBA

Trey" <tr***********@hotmail.com> wrote in message
news:Sv*****************@twister.socal.rr.com...
How do I tell an update query to only search the records that are older then
the current record?

I need to figure out how to write a query that will take a record, look
to
see if any record with an older date and time has the same address, then
marks a yes/no box to YES if it does not find a duplicate.

I know this can be done, I just don't know how.

I know it will take a subquery of some kind. I am just lost. Any help would
be very much appreciated!
Nov 13 '05 #4
John Winterbottom wrote:
"Trey" <tr***********@hotmail.com> wrote in message
news:Sv*****************@twister.socal.rr.com...
How do I tell an update query to only search the records that are
older then the current record?

I need to figure out how to write a query that will take a record,
look to see if any record with an older date and time has the same
address, then marks a yes/no box to YES if it does not find a
duplicate.

I know this can be done, I just don't know how.

I know it will take a subquery of some kind. I am just lost. Any
help would be very much appreciated!

Normally it would take a subquery - unfortunately that doesn't work
in Jet. You need to use domain aggregate functions or
"queries-feeding-queries". Give us some more info and someone will be
able to write the sql for you.

I have a table named "main". then I have a query named "12month", this query
selects only the records in the table that are 12 months old and newer. From
this point on, that is the only data that I will be working with for this
operation.

SQL for 12month:
SELECT DateDiff('m',[date_called],Date()) AS expr1, [main].[date_called],
[main].[call_count], [main].[Address], [main].[Zip], [main].[Billable],
[main].[Bill_sent], *
FROM main
WHERE (((DateDiff('m',[date_called],Date()))<=12))
ORDER BY [main].[date_called], [main].[Address];
---------------
This part works great. But now comes the update query that I am having
trouble with.
I have some ugly bastardized SQL that I have glued together. This update
query is able to find any records that do not have duplicate addresses, and
mark the warning = yes.

UPDATE 12month SET 12month.Warning = Yes
WHERE [12month].address = (SELECT [12month].Address
FROM 12month WHERE ((([12month].Address) In (SELECT [Address] FROM [12month]
As Tmp GROUP BY [Address] HAVING Count(*)<=1 )))
ORDER BY [12month].Address);
-------------
However, it searches all the records, not just the records that are older
then the current record. So instead of looking at a record, seeing if an
OLDER duplicate address exists, and marking the warning = yes accordingly,
it searches all the records. And if any duplicates exist (including new
duplicates) then it wont mark it.

I am afraid I did not explain this correctly, but this is the best I can do
with my limited SQL knowledge.

Thanks in advance for your help.


Nov 13 '05 #5

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

Similar topics

9
by: majsen | last post by:
Hi, I have problem running this query. It will time out for me... My database are small just about 200 members. I have a site for swaping appartments (rental). my query should look for match in...
8
by: Együd Csaba | last post by:
Hi All, how can I improve the query performance in the following situation: I have a big (4.5+ million rows) table. One query takes approx. 9 sec to finish resulting ~10000 rows. But if I run...
3
by: John Ortt | last post by:
> I have a table of dates in ascending order but with varying intervals. I > would like to create a query to pull out the date (in field 1) and then pull > the date from the subsequent record...
3
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table...
7
by: serge | last post by:
How can I run a single SP by asking multiple sales question either by using the logical operator AND for all the questions; or using the logical operator OR for all the questions. So it's always...
6
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
2
by: mmitchell_houston | last post by:
I'm working on a .NET project and I need a single query to return a result set from three related tables in Access 2003, and I'm having trouble getting the results I want. The details: ...
22
by: Stan | last post by:
I am working with Access 2003 on a computer running XP. I am new at using Access. I have a Db with a date field stored as mm/dd/yyyy. I need a Query that will prompt for the month, ie. 6 for...
3
by: Richard Hollenbeck | last post by:
I am very sorry about the (almost) re-post, but you will see that my first question wasn't very clear; I have another question I posted this morning called, "in DAO: Run time error 3061 Too few...
16
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.