Three Tables - Multiple Join Duplication

May 1, 2014

When I join three tables I get duplicated records in Access SQL. How can I solve this? Using distinct is no options.

View Replies


ADVERTISEMENT

Query - JOIN Multiple Tables

Jun 11, 2006

Hello All;

Could someone please assist me on this?

The following is the Tables:

ContentTypes ---> Site Content Directory
Cats ---> Categories
Sierra ---> Store Content for Sierra
BrushStrokes ---> Store Content for BS

I have "tried" to create a QUERY for the 4 Tables
(The code that I have, originally came with 3-Table Query connection
I have added in the 4th Table "BrushStrokes")

This is the Query that I created. Before the code, a little insite

At first there was: RIGHT & LEFT JOIN's, But I would receive this:
Error 3258
After not really finding any good examples of how to create the
2- Queries and have then work together as one.
I decided to try something else, which was to create all [INNER JOIN]'s
Which got rid of the Error, and the code still will not work in my site.
========
Microsoft JET Database Engine error '80040e14'
Syntax error in JOIN operation.
=======

So, here is the code, please let me know what is wrong with it?
And if possible, a good example of creating the [2 - Queries] that work as one.

Thank you all
Carrzkiss
-----------------------SQL QUERY------------------
SELECT Cats.CatID, Sierra.CatID, BrushStrokes.CatID, Sierra.ContentID, BrushStrokes.BSContentID, Sierra.Product_Title, BrushStrokes.BSProduct_Name, Cats.CatDescription, Cats.CatTypeId, Sierra.Product_Th_Image, BrushStrokes.BSThumbnail, Sierra.Our_Price, BrushStrokes.BSPrice, Sierra.Retail_Price, BrushStrokes.BSRetail, Sierra.Aff_Name, BrushStrokes.Aff_Name, Sierra.Brand_Name, BrushStrokes.BSArtistName, Sierra.YAvailable, BrushStrokes.BSStatus, Sierra.Percent_Savings, Sierra.Unique_Product_ID, BrushStrokes.BSProductID, Sierra.Main_Cat, BrushStrokes.BSCol_Cat, ContentTypes.ContentType, Sierra.Product_Description, BrushStrokes.BSDescription
FROM ((ContentTypes INNER JOIN Sierra ON ContentTypes.ContentTypeID = Sierra.ContentTypeID) INNER JOIN BrushStrokes ON ContentTypes.ContentTypeID = BrushStrokes.ContentTypeID) INNER JOIN Cats ON (BrushStrokes.CatID = Cats.CatID) AND (Sierra.CatID = Cats.CatID)
WHERE (((Sierra.Display)=1) AND ((BrushStrokes.Display)=1));
-----------------------------END SQL QUERY------------------

View 3 Replies View Related

Query Multiple Tables Using INNER JOIN And Multivalue Fields

Jan 28, 2013

Here is my current table structure (I have omitted some fields from this example and have given some sample data in italics to make the table structure more clear.

tblEmployees

ID (autonumber) 3
EmployeeName John
EmployeePhone 555999555
EmployeeLocation New York

tblClients

ClientID (autonumber) 1 , 2 , 3
ClientName ABC Company , XYZ Company, PQR Company
fkeyLocationID

tblLocations
LocationID 1 , 2
Location New York , Chicago

tblEmployeeClients (junction table)
fkeyID 3
EmployeeClients (multivalued number) 1,2

The junction table tblEmployeeClients only stores ID of the Employee and in the second column (which is a multi-valued field), the ID of each of the clients the employee Supports.

I am trying to generate a report that lists say, EmployeeName alongside the clients supported by the Employee (listing the client location is not required, however, it would be good to know how to do that as well).

The report (for the example above), should look like this:

Name Clients Supported
John ABC Company, PQR Company

Currently, I am able to get :

John 1, 2 i.e the client ID for the clients that the employee supports instead of the corresponding company names.

View 1 Replies View Related

Tables :: Prevent Duplication In Table

Jun 11, 2015

i have a table called tbl1. in this table i have field month, year, or trainee. is it possible that above mentioned three field found same data table automatically delte those rows. so i found only unique data. or their is another way to make this possible.

View 2 Replies View Related

Create A JOIN Of Different Tables Called Join A Variable And List

Nov 16, 2013

And then called this join as a symbol or variable, and then have it use to select the items from these joined tables, can this be done in Access? Here is an example of a code that I created, but it has an error message saying the FROM syntax is incorrect.

Code:
SELECT firstJOIN.trainID, firstJOIN.trainName, firstJOIN.stationID, firstJOIN.stationName, firstJOIN.distance_miles, firstJOIN.time_mins
FROM (trains INNER JOIN ((station INNER JOIN lineStation ON station.stationID = lineStation.stationID)
INNER JOIN bookingLeg ON bookingLeg.startID = station.stationID or bookingLeg.endID = station.stationID )
ON trains.trainID = bookingLeg.tid) as firstJOIN

Can Access do something similar to this, in the FROM statement I joined 4 tables, because each unique fields are in each table and I have to joined them to get those fields. I called this join firstJOIN and in the SELECT statement, I list those columns in the table by calling it firstJOIN.trainID. Can Access do something like this, but syntax it differently?

View 6 Replies View Related

Join Tables SQL = Problem = My Tables Are Not Normalized

Dec 15, 2005

Okay - the other database is in the works and is going sloooow (the one that is being created with normalization).

Meanwhile, my other database that has no normalization I am having a problem running a query (now I know why its so important to have good structure).

To give you an idea on how bad this is...:o .....

3 tables - 94 fields to each table - each table has identicle fields, just different data. :eek:

Anyways, I have students in each table (each table is an Annual Report). I want to be able to run a simple query and combine all the students into one.

How would I achieve this?

Thank you!

And for all who are thinking about designing a database - READ READ READ and do some more reading on normalization!!!

View 3 Replies View Related

Multiple Join Problem

Feb 11, 2005

I am working on a "course registration" system using asp (vbscript) and MS Access. There are 4 tables as shown:

activity (1 entry per course - key is ActivityID)

activitysections (1 entry for each course section for an activity - key is SectionID - ActivityID is also in the record)

registrations ( 1 entry for each registrant in the section - key is RegistrationID - Section ID and PersonID are also in the record)

users ( 1 entry for each student with their demographic info - PersonID is the key)

When I run the following query on the test Access database:

SELECT activity.ActivityName, activity.ActivityStatus, activity.ActivityID, activitysections.SectionNumber, activitysections.SectionStatus, activitysections.SectionSchedule, activitysections.SectionCapacity, activitysections.SectionParticipants, activitysections.SectionDuration, users.FirstName, users.Initial, users.LastName, users.NameSuffix, users.PreferredName, users.Gender, users.BirthDate
FROM users INNER JOIN ((activity INNER JOIN activitysections ON activity.ActivityID = activitysections.ActivityID) INNER JOIN registrations ON activitysections.SectionID = registrations.SectionID) ON users.PersonID = registrations.PersonID;

I get the correct results - 1 entry wherever there is a registrant for a section of an activity.

However, I want to run a query that lists all the sections regardless of whether there is a person registered. To do that I changed the query to a left join as follows:

SELECT activity.ActivityName, activity.ActivityStatus, activity.ActivityID, activitysections.SectionNumber, activitysections.SectionStatus, activitysections.SectionSchedule, activitysections.SectionCapacity, activitysections.SectionParticipants, activitysections.SectionDuration, users.FirstName, users.Initial, users.LastName, users.NameSuffix, users.PreferredName, users.Gender, users.BirthDate
FROM users INNER JOIN ((activity INNER JOIN activitysections ON activity.ActivityID = activitysections.ActivityID) LEFT JOIN registrations ON activitysections.SectionID = registrations.SectionID) ON users.PersonID = registrations.PersonID;

I get this wonderful little message saying "join expression not supported". Can anyone give me some advice on what I am doing incorrect. Thanks.....

View 3 Replies View Related

Using 2 Sum Functions In Multiple Join Query.

Sep 16, 2004

I have a problem with using two Sum() functions in a multiple join query. It is an Access database that is accessed by VB6.

These are my tables with some sample records:-

Payment(payID, payCustID, payDate, payAmount)
1, 4, 30/09/2004$5.00
2, 4, 30/09/2004$120.00
3, 4, 30/09/2004$20.00

Customer(custID, custName)
1, steven
2, julie
3, blake
4, kate

Invoice(invID, invCustID, invDate, invAmount)
1, 1, 10/09/2004, $50.00
2, 2, 11/09/2004, $50.00
3, 1, 11/09/2004, $150.00
4, 3, 10/09/2004, $20.00
5, 4, 10/09/2004, $5.00
6, 4, 11/09/2004, $120.00

This is my query:-
SELECT DISTINCTROW Customer.custName, Sum(Invoice.invAmount) AS SumOfinvAmount, Sum(Payment.payAmount) AS SumOfpayAmount
FROM (Customer LEFT JOIN Invoice ON Customer.custID = Invoice.invCustID) LEFT JOIN Payment ON Customer.custID = Payment.payCustID
GROUP BY Customer.custName, Customer.custID;

Result:-
custName SumOfinvAmount SumOfpayAmount
blake $20.00
julie $50.00
kate $375.00 $290.00
steven $200.00


The resulting SQL query returns incorrect invoice and payment totals for Kate. The Sum() function has duplicated. Can anyone tell me how I would change my query to fix this problem?


Thanks Steven

View 1 Replies View Related

Multiple Join Delete Query

Nov 16, 2014

I am trying to delete all records on [TableA] that Match [TableB] at Columns [SKU] and [ASIN].

View 1 Replies View Related

Reports :: Join Together Multiple Rows To One Field?

Jul 1, 2015

I have been struggling with combining multiple rows into one row for an order summary report.

Specifically, I have three tables (Products, Orders, and OrderDetails)

Products
=======
ProductID = AutoNumber
ProductName = String

Orders
======
OrderID = AutoNumber
OrderDate = Date/Time
OrderInfo = Memo
CustomerName = Text
CustomerAddress = Text
PaymentDetails = Text

OrderProductDetails
=========
OrderNumber = Number (Linked to OrderID)
ProductNumber = Number (Linked to ProductID)
Notes = Memo (Notes on product customization)

The OrderProductDetails table is in many to one relationships with both Orders and Products table. If I place an order with 3 products, the OrderProductDetails datasheet would be:

OrderNumber ProductNumber
========================
1 78 (Product 1)
1 89 (Product 2)
1 56 (Product 3)

On my report, instead of 3 entries for this order, I would like show just one entry under a column "Products Ordered" ---> Product 1, Product 2, Product 3.

I tried the Concatenate macros I found online, however, I am unable to configure them properly to use for this purpose.

I am using Access 2010.

View 10 Replies View Related

How To Join 3 Tables?

Feb 25, 2005

helooo...

i have 3 tables -Recipes, Ingredients and Products.

Recipes table:
RecipeID -PK

Ingredients table:
IngredientID -PK
IngreRecipeID -Foreign key to Recipes table
IngreProductID -Foreign key to Products table

Table:
ProductID -PK

how do i join them into 1 recordset? :confused:

View 1 Replies View Related

Join Tables

Jul 11, 2005

HELP!!! :confused: I do have a 5 tables 4 tables do have a foreign key of the main table. I join the 4 tables with the main table but when I am editing the information I cannot edit it. and no error appears. so I am just wondering what happen with my joined tables? please help me!!!!Thank you in advance

View 1 Replies View Related

Join Tables

Apr 3, 2006

How do I join two tables. I have a table and a lookup table. My table has products on there that are listed as custom or basic. I have a look up table that has an ID for basic and Custom. In my table, i want it to read what the id is for each product instead of it reading "basic" or custom. Someone said that I need to join the two tables and do an update query, but I don't understand how to.

View 3 Replies View Related

To Join Tables Or Not To Join Tables

Mar 24, 2008

That is the question:
Whether 'tis nobler in the mind to suffer
with VBA Programming and the outrageous errors,
Or to take up arms against a sea of Access troubles.

Sorry I was in the mood for Shakespeare.

A quick summary first:
In the attached file I have my Relationships. One main table, Workorders with various one-to-many relationships back to their respective tables. If you look at the attachment and see a field with 'wrk' that's my foreign key.

What I'm trying to do is this:
Where-ever there is a 'wrk' field I want to add in all the fields (minus the ID Primary Key) into the main Workorders Form.

Then on the form itself I should just be able to enter in the data that is required for the fields.

So here's what I'm thinking for the coding is to Join the various tables to thlet me know if I'm on track or not. I'll start with a small one, because if I can get that right, the rest should be simple.

SELECT Model.ComputerID, Make.ComputerID
FROM Computer
INNER JOIN wrkComputerID ON Model.ComputerID = Make.ComputerID;

View 6 Replies View Related

JOIN Three Tables

Dec 12, 2005

Hi,

I've got three tables:

tblEvent
--------
Id (PK) | Event_Name



tblDelegate
--------
Id (PK) | Delegate_Name



tblBooking
--------
Id (PK) | Event_Id (FK) | Delegate_Id (FK)





I need to retrieve a recordset with the following information:

Booking Id | Event_Name | Delegate_Name


Can anyone see how to do a SELECT statement to do this?

ANy help would be great, thanks!

View 2 Replies View Related

JOIN 4 Tables!?

Dec 20, 2005

Hi,

I have the following four tables:

tblGroup:

Group_Id (PK) | Group_Name


tblSubGroup:

SubGroup_Id (PK) | Group_Id (FK) | SubGroup_Name


tblProductType:

ProductType_Id (PK) | SubGroup_Id (FK) | ProductType_Name


tblProduct:

Product_Id (PK) | ProductType_Id (FK) | Product_Name




I need to select a single Product_Name (first one which appear alphabetically) from tblProducts given a Group_Id.

Is this possible? Presumably I need to join the tables in between?

If anyone can help with this it would be much appreciated, thanks...

View 8 Replies View Related

How Can I Join These Tables?

Jun 30, 2005

there must be a way to do this, but i haven't been able to figure it out yet...

table one has three fields i need to be concerned with, member_ID, range_start, and range_end. no part of any range spanning range_start through range_end will be duplicated.

table two has several fields i need, but the field of primary concern is a person_ID that will fall somewhere within a range designated in the first table.

how in the world can i join these tables, since none of the IDs in the second table are actually listed in the first, but fall in between values?

i need to get member_ID from table one, person_ID and several other fields from table two.

any ideas?

thanks for any help,
john

View 4 Replies View Related

Need Help In Sql How To Join 2 Tables Into 1

Oct 2, 2005

hi

i have 2 tables, A and B
A table
StockDate Price
02/04/2001 1.12
04/05/2001 1.15
14/08/2002 1.14
18/09/2003 1.26
and so on 1.48
up to 2005

B Table
StockDate Price
02/04/2003 1.12
04/05/2003 1.15
14/08/2003 1.14
18/09/2004 1.26
and so on 1.48
up to 2005


i like to know how to write codes to join 2 tables into 1 table like
C Table
StockDate Price
02/04/2001 1.12
04/05/2001 1.15
14/08/2002 1.14
18/09/2003 1.26
02/04/2003 1.12 --> B Table
04/05/2003 1.15
14/08/2003 1.14
18/09/2004 1.26
and so on 1.48


regards
ellen

View 2 Replies View Related

How Do You Join Two Tables?

Jan 30, 2007

how do you join two tables?

help plz. thank you!

View 5 Replies View Related

More Than One Join Between Two Tables?

Aug 22, 2014

What is the purpose or the advantage to doing more than one join between two tables? How many joins can you have between two tables?

View 2 Replies View Related

ADO Using An Sql Statement To Join Tables

Sep 5, 2005

Hi there

I am hoping someone can give me a few pointers on how to get started on what I am trying to achieve....

I have 2 tables that form a 1 - to - many relationship.

I have designed a form that I wish to show fields from both tables.

Using ADO I would like to be able to open the form and be able to see my desired fields in the same form.


Can anyone provide any ideas on where I can get started.


Thanks for your help!!

View 3 Replies View Related

2 Tables, No Relationship, Need To Join

Dec 20, 2004

First time user!!!

I work for the school dist. and we have 2 tables for 2 different groups.
I need to pull data from them both and create a new Query.
Example
Table 1:
Name, address, phone

Table 2:
Name, address, phone

(No similarities in ether database, and we'd like to NOT export data)

I'm hoping it's an easy fix that I've overlooked.
Michelle

View 2 Replies View Related

Help Need Creating A Join Between 3 Tables

Sep 6, 2005

Hi there

I have made a form I am trying to bound 3 tables to.

The 3 tables are

tblPersonalInfo
tblBookingInfo
tblSkills

How I am trying to set it up is that I enter someones personal details in once. But using the same personal details someone can have more then one booking.
With the skills....each person can have lots of different skills.

Basically I work for a recruitment agency and I have been asked to build a database that can add new people.add skills to that person.....then add different jobs to the same person.

I have made 3 tables

tblPersonalInfo
PersonalID
chrForename
chrSurname
dtmDOB
chrEmail

tblBookingInfo
BookingID
chrJobTitle
curPayRate
PersonalID
SkillsID

tblSkills
SkillsID
Skills


I have joined all tables togeather (I think wrong but trying) the tblbookinginfo is joined to tblbooking using a 1 - Many relationship using the primary key of tblPersonalInfo to the field PersonalID in the table tblBookingInfo
I have joined tblSkills to the table tblbookingID through SkillsID

I created a query using all 3 tables and have used this to bound the form....

The form contains 3 pages and the 1st page works ok (it only contains info from the tblPersonalInfo) the 2 other pages don't seem to work as I want them to.


I would like to be able to click to add a new person and also new booking and new skills

Currently I am able to add new personal details but nothing else.

Can anyone see what I am doing wrong?

Thanks for taking the time to read this

View 11 Replies View Related

Join Tables Into A New Table

Jul 13, 2005

Have some problems with a Purchase Order (PO) System I'm trying to do.

Figure 1 is the PO entry form. The upper part of the form shows the Header, while the bottom part shows the Line, containing all the ordered item details.

I separated the information keyed in into 2 tables, namely Header table (Figure 2) and Line table (Figure 3). The header table shows only the header details. With the order ID, the header is linked to the Line table where all the ordered items detail can be found.

I want to join the 2 tables and put the data into a new table, which will later be exported to text/spreadsheet for other purposes. I know it can be done using the make-table query. But my concern is about the layout/format of the table.

I would want to put my data where there's one header row followed by the corresponding line rows. Then another new header row with its line rows. I'll give an example:

H XXX XXXXXXXX XX X
L XXXXX XXX XX
L XXXXX XXX XX
L XXXXX XXX XX
H XXX XXXXXXXX XX X
L XXXXX XXX XX
L XXXXX XXX XX
L XXXXX XXX XX
L XXXXX XXX XX

Note that not all the fields for Header row and Line rows are the same. So can I put different data into the same column?

Would appreciate it if anyone could solve my problems. Thanks. ;)

View 1 Replies View Related

Sql For Insert Into Join Tables

Nov 6, 2007

Hi,
I have an unbound form that is based on a query. On the Load-event I have populated textboxes with the underlying records (it works fine).

The underlying query is based on 2 tables that are joined on (PrimaryKey) Table1.ID = Table2.ID (ForeignKey).

The Form has one Add-CmdButton. When the user will click the Add-button the content of the textbox will get added or saved in the underlying database.

I want to know the SQL to add, so that I can write the code behind on the Click-event of the button.

I know on how to add records with a single table (writing code behind), however, I want to know on how to do when it comes with joined tables (INSERT SQL statement ?).

Thanks and regards,
Prodigy.

View 1 Replies View Related

Join Two Tables In A Query

Feb 13, 2005

I would like to join two tables with one query. Here is the twist though.
The first table would have a set of value like so:

0
50
100
300
500
750
1200
1500

the second table would have values as such

0
1000
1300
1500
1750

by just setting up the relationship to show all values from the sirt table and only those from the second table that match I get a list of values that will not work for me. What I would like to reflect
in the query is all the values from the first table and if there is for instance no value of 500 in the second table I would like to return 1000. For instance there is a zero in each table so that would be output twice. There is however no value of 50 in the second table so the query would read 50 and null or blank when I would like it to read 50 and 1000 (The next value higher).

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved