data from one table to another.

User avatar
Steve_in_Kent
4StarLounger
Posts: 422
Joined: 04 Feb 2010, 11:46

data from one table to another.

Post by Steve_in_Kent »

I want one table column to look up data in another column.. and i thought this would work, but it doesn't !

SELECT [LkupDATES].[CINCOMWEEK] FROM LkupDATES WHERE VOLUME.[PRODUCTION DATE]=LkupDATES.myDATE;

LkupDATES and Volume are the tables

cincomweek is the Text field i want to place in the new table column.

production date and myDate are date fields that match to determine what cincomweek to place in the new table.

Steve
----------------------------------------------------------------------------------------
Owing at LEAST 34 beers to other helpful forum members. Especially HansV!

User avatar
HansV
Administrator
Posts: 78650
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: data from one table to another.

Post by HansV »

If it's lookup information, why do you want to store it in a table? That would be redundant. You can retrieve the value at any moment using a query.
Best wishes,
Hans

User avatar
Steve_in_Kent
4StarLounger
Posts: 422
Joined: 04 Feb 2010, 11:46

Re: data from one table to another.

Post by Steve_in_Kent »

Yes, i know its not optimal to do so. but i just need the one table to contain information from the other table based on the dates.
----------------------------------------------------------------------------------------
Owing at LEAST 34 beers to other helpful forum members. Especially HansV!

User avatar
HansV
Administrator
Posts: 78650
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: data from one table to another.

Post by HansV »

Then you need an update query:

UPDATE VOLUME INNER JOIN LkupDATES ON VOLUME.[PRODUCTION DATE]=LkupDATES.myDATE SET VOLUME.CINCOMWEEK=LkupDATES.CINCOMWEEK

assuming that the field is named CINCOMWEEK in both tables.
Best wishes,
Hans

User avatar
StuartR
Administrator
Posts: 12632
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: data from one table to another.

Post by StuartR »

Steve_in_Kent wrote:...i just need the one table to contain information from the other table based on the dates.
I am curious.

What is the real underlying "need" here. I would be very surprised if it cannot be met with a different solution that doesn't copy data between tables.
StuartR