Question about fields, table relationships & sql

mercredi 22 avril 2015

I have 3 tables. The field in red is the problem area.

tblTypes: (PK)TypeID, Type
tblAccounts: (PK)AcctID, (FK)TypeID, AcctName
tblJournalEntries: (PK)JournalID, Date, (?)TypeID, (FK)AcctID, Amount

screenprint uploaded here if it helps--> h t t p ://imgur.com/ktRdNNE

So my confusion is with tblJournalEntries. I don't think I have it set up correctly. I want to be able to select TypeID (expense, income, etc) and have AcctNames show only the matching TypeID.

SELECT [tblAccounts].[AcctID], [tblAccounts].[AcctName] FROM [tblAccounts] ORDER BY [AcctName]; shows all accounts regardless of type.

I tried using this but the field came up blank: SELECT DISTINCTROW [tblAccounts].[AcctID], [tblAccounts].[AcctName] FROM tblAccounts WHERE ((([tblAccounts].[TypeID])=[tblJournalEntries].[TypeID] ORDER BY [AcctName]));

Any help or suggestions would be much appreciated. Thanks.
Question about fields, table relationships & sql

0 commentaires:

Enregistrer un commentaire

Labels