Re: Lookup in Query
- From: jbgarrett1 <jbgarrett1@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 17 Mar 2006 11:57:21 -0800
UPDATE table1
SET table1.Rec_FW = ( SELECT table2.Fiscal_Week
I don't want the Rec_Date field to be updated. I want the Query to use the
Rec_Date field and compare to the other table and then put the fiscal week
into a field called Rec_FW. I thought the "SET" line in my first query would
have done that, but it's not actually changing the value to the fiscal week.
"Tom Ellison" wrote:
Dear JB:.
Sorry, no, it doesn't make sense to me right now. How can you update a
date/time column (Rec_Date) to be a week?
Tom Ellison
"jbgarrett1" <jbgarrett1@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:B2434ACB-0887-420F-9F0B-C97C94F9B843@xxxxxxxxxxxxxxxx
Tom,
This is pulling the right record, but I need the query to actually update
Rec_Date to the fiscal week.
Does that make sense?
"Tom Ellison" wrote:
Dear JB:
Let's make it simpler. Test just a SELECT query:
SELECT table1.Rec_FW, table2.Fiscal_Week
FROM table1, table2
WHERE table1.Rec_Date BETWEEN table2.Saturday AND table2.Friday
AND EXISTS
(SELECT table2.Fiscal_Week
FROM table2
WHERE table1.Rec_Date BETWEEN table2.Saturday AND table2.Friday)
Next, does this do anything different:
SELECT table1.Rec_FW, table2.Fiscal_Week
FROM table1, table2
WHERE table1.Rec_Date BETWEEN table2.Saturday AND table2.Friday
If the specific row does not exist, I don't think the latter query would
return that anyway.
I hope this looks like progress. Please let me know what you find.
Tom Ellison
"jbgarrett1" <jbgarrett1@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C6B14F8C-F2BF-439A-ABDB-5C5468334318@xxxxxxxxxxxxxxxx
Sorry to be so vague.
Here is my SQL Statement
UPDATE table1
SET table1.Rec_FW = ( SELECT table2.Fiscal_Week
FROM table2
WHERE table1.Rec_Date BETWEEN table2.Saturday AND table2.Friday)
WHERE EXISTS
( SELECT table2.Fiscal_Week
FROM table2
WHERE table1.Rec_Date BETWEEN table2.Saturday AND table2.Friday);
This is returning the right amount of Records when I run it, but it is
not
actually updating that field. They are just left blank.
- Follow-Ups:
- Re: Lookup in Query
- From: Tom Ellison
- Re: Lookup in Query
- References:
- Re: Lookup in Query
- From: Tom Ellison
- Re: Lookup in Query
- From: Tom Ellison
- Re: Lookup in Query
- From: Tom Ellison
- Re: Lookup in Query
- Prev by Date: MS Access Query - Selecting Certain Entries In A Field
- Next by Date: Re: SQL 2005 ORDER BY is ignored where form is based on a view in a AD
- Previous by thread: Re: Lookup in Query
- Next by thread: Re: Lookup in Query
- Index(es):
Relevant Pages
|