A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Linking Tables



 
 
Thread Tools Display Modes
  #1  
Old February 26th, 2010, 01:52 PM posted to microsoft.public.access
Logo
external usenet poster
 
Posts: 29
Default Linking Tables

I have 2 tables linked in a one to many relationship. Problem is, one table
has values that are entered daily, and the other table has values that are
entered monthly. When I try to create a query joining the two tables, the
monthly values aren't joining with the daily values correctly. There must be
a way to do this? TIA
--
Logo
  #2  
Old February 26th, 2010, 06:00 PM posted to microsoft.public.access
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default Linking Tables

Logo -

Can you give us the table names, the pertinent fields, and what you mean by
not joining correctly? Please post your SQL also so we may be able to help.

--
Daryl S


"Logo" wrote:

I have 2 tables linked in a one to many relationship. Problem is, one table
has values that are entered daily, and the other table has values that are
entered monthly. When I try to create a query joining the two tables, the
monthly values aren't joining with the daily values correctly. There must be
a way to do this? TIA
--
Logo

  #3  
Old March 1st, 2010, 09:40 AM posted to microsoft.public.access
Stefan Hoffmann
external usenet poster
 
Posts: 991
Default Linking Tables

hi,

On 26.02.2010 14:52, Logo wrote:
I have 2 tables linked in a one to many relationship. Problem is, one table
has values that are entered daily, and the other table has values that are
entered monthly. When I try to create a query joining the two tables, the
monthly values aren't joining with the daily values correctly. There must be
a way to do this? TIA

The question is: how do you ensure referential integrity? Which fields
do you use?

Basically there are two common scenarios:

a) surrogate keys, thus your monthly values are stored in a table with
an AutoNumber field:

SELECT M.*, D.*
FROM dailyTable D
INNER JOIN monthlyTable M
ON M.ID = D.idMonth;

b) you have a normal key over the date
b1) you are storing the date in atomic values for year, month and day:

SELECT M.*, D.*
FROM dailyTable D
INNER JOIN monthlyTable M
ON M.year = D.year
AND M.month = D.month;

b2) you are storing the date in a single Date/Time field:

SELECT M.*, D.*
FROM dailyTable D
INNER JOIN monthlyTable M
ON Year(M.monthDate) = Year(D.monthDate)
AND Month(M.monthDate) = Month(D.monthDate);


mfG
-- stefan --
  #4  
Old March 13th, 2010, 05:58 PM posted to microsoft.public.access
De Jager
external usenet poster
 
Posts: 393
Default Linking Tables


"Stefan Hoffmann" wrote in message
...
hi,

On 26.02.2010 14:52, Logo wrote:
I have 2 tables linked in a one to many relationship. Problem is, one
table
has values that are entered daily, and the other table has values that
are
entered monthly. When I try to create a query joining the two tables,
the
monthly values aren't joining with the daily values correctly. There
must be
a way to do this? TIA

The question is: how do you ensure referential integrity? Which fields do
you use?

Basically there are two common scenarios:

a) surrogate keys, thus your monthly values are stored in a table with an
AutoNumber field:

SELECT M.*, D.*
FROM dailyTable D
INNER JOIN monthlyTable M
ON M.ID = D.idMonth;

b) you have a normal key over the date
b1) you are storing the date in atomic values for year, month and day:

SELECT M.*, D.*
FROM dailyTable D
INNER JOIN monthlyTable M
ON M.year = D.year
AND M.month = D.month;

b2) you are storing the date in a single Date/Time field:

SELECT M.*, D.*
FROM dailyTable D
INNER JOIN monthlyTable M
ON Year(M.monthDate) = Year(D.monthDate)
AND Month(M.monthDate) = Month(D.monthDate);


mfG
-- stefan --


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:55 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.