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 » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

SQL Statment Help Needed



 
 
Thread Tools Display Modes
  #1  
Old May 9th, 2008, 04:11 PM posted to microsoft.public.access.queries
Query Help
external usenet poster
 
Posts: 1
Default SQL Statment Help Needed

I have 22011 records in table "tblProcChargCounty " when I create a query
between this table and tblFacility table, I have 22011 records, but I try to
add "tblEquipType" table I get bigger number. Now table tblEquipType &
tblProcChargCounty have one-to-Many relationship with tbleFacility table.

I need help with this please

SELECT CODE, OpenFacility, FACILITY, FacilityType, COUNTY
FROM tblFacility
UNION All
Select Year, BeginningDate, EndingDate, County AS tblProcChargCounty_County,
PETProc
FROM tblProcChargCounty

SELECT Code, EquipType, [Replacement/Upgrade], [Active?], DateAquired,
[Owned/Leased], [Fixed/Mobile], [Shared?]
FROM tblEquipType;

  #2  
Old May 9th, 2008, 04:36 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default SQL Statment Help Needed

It appears that tblProcChargCounty joins tblFacility on COUNTY but I do not
see a common field to join tblEquipType. How is it related?

--
KARL DEWEY
Build a little - Test a little


"Query Help" wrote:

I have 22011 records in table "tblProcChargCounty " when I create a query
between this table and tblFacility table, I have 22011 records, but I try to
add "tblEquipType" table I get bigger number. Now table tblEquipType &
tblProcChargCounty have one-to-Many relationship with tbleFacility table.

I need help with this please

SELECT CODE, OpenFacility, FACILITY, FacilityType, COUNTY
FROM tblFacility
UNION All
Select Year, BeginningDate, EndingDate, County AS tblProcChargCounty_County,
PETProc
FROM tblProcChargCounty

SELECT Code, EquipType, [Replacement/Upgrade], [Active?], DateAquired,
[Owned/Leased], [Fixed/Mobile], [Shared?]
FROM tblEquipType;

  #3  
Old May 9th, 2008, 07:14 PM posted to microsoft.public.access.queries
Query Help[_2_]
external usenet poster
 
Posts: 1
Default SQL Statment Help Needed

All tables are join to tblfacility on Code, even tblEquipType.

"KARL DEWEY" wrote:

It appears that tblProcChargCounty joins tblFacility on COUNTY but I do not
see a common field to join tblEquipType. How is it related?

--
KARL DEWEY
Build a little - Test a little


"Query Help" wrote:

I have 22011 records in table "tblProcChargCounty " when I create a query
between this table and tblFacility table, I have 22011 records, but I try to
add "tblEquipType" table I get bigger number. Now table tblEquipType &
tblProcChargCounty have one-to-Many relationship with tbleFacility table.

I need help with this please

SELECT CODE, OpenFacility, FACILITY, FacilityType, COUNTY
FROM tblFacility
UNION All
Select Year, BeginningDate, EndingDate, County AS tblProcChargCounty_County,
PETProc
FROM tblProcChargCounty

SELECT Code, EquipType, [Replacement/Upgrade], [Active?], DateAquired,
[Owned/Leased], [Fixed/Mobile], [Shared?]
FROM tblEquipType;

  #4  
Old May 9th, 2008, 08:51 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default SQL Statment Help Needed

Use a LEFT JOIN on CODE.
SELECT tblEquipType.Code, tblEquipType.EquipType,
tblEquipType.[Replacement/Upgrade], tblEquipType.[Active?],
tblEquipType.DateAquired, tblEquipType.[Owned/Leased],
tblEquipType.[Fixed/Mobile], tblEquipType.[Shared?],
tblFacility.OpenFacility, tblFacility.FACILITY, tblFacility.FacilityType,
tblFacility.COUNTY, tblProcChargCounty.Year,
tblProcChargCounty.BeginningDate, tblProcChargCounty.EndingDate,
tblProcChargCounty.County AS tblProcChargCounty_County,
tblProcChargCounty.PETProc
FROM (tblEquipType LEFT JOIN tblFacility ON tblEquipType.Code =
tblFacility.CODE) LEFT JOIN tblProcChargCounty ON tblEquipType.Code =
tblProcChargCounty.CODE;

--
KARL DEWEY
Build a little - Test a little


"Query Help" wrote:

All tables are join to tblfacility on Code, even tblEquipType.

"KARL DEWEY" wrote:

It appears that tblProcChargCounty joins tblFacility on COUNTY but I do not
see a common field to join tblEquipType. How is it related?

--
KARL DEWEY
Build a little - Test a little


"Query Help" wrote:

I have 22011 records in table "tblProcChargCounty " when I create a query
between this table and tblFacility table, I have 22011 records, but I try to
add "tblEquipType" table I get bigger number. Now table tblEquipType &
tblProcChargCounty have one-to-Many relationship with tbleFacility table.

I need help with this please

SELECT CODE, OpenFacility, FACILITY, FacilityType, COUNTY
FROM tblFacility
UNION All
Select Year, BeginningDate, EndingDate, County AS tblProcChargCounty_County,
PETProc
FROM tblProcChargCounty

SELECT Code, EquipType, [Replacement/Upgrade], [Active?], DateAquired,
[Owned/Leased], [Fixed/Mobile], [Shared?]
FROM tblEquipType;

 




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 03:21 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.