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 Replies
ADVERTISEMENT
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
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 4 Replies
View Related
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
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
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
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
Aug 23, 2006
Hi!
Thanks for all help so far, this forum is great ;)
I have 3 tables: Order, Product and Names.
I want to list All orders, no matter if they hold a key to a product or not, and no matter if this product has been given a name (in the table name) or not.
To make it even more complicated, the customer can give upp to 16 namesuggestions, they are all numbered from 1-16. But If they are given a namesuggestion, i only want to present the first one (nr 1).
Relations: 1 order -> 0 or 1 product.
1 order -> 0 or up to 16 names, of which i only want to display nr 1.
Any suggestions?
I am thinking of preparing the data in a temporary table, but would be glad if i did not need to do so....
View 1 Replies
View Related
Apr 5, 2006
Can someone please help with the following:
I am trying to join two tables in a query. One of the tables has only the fullname while another has only the surname (this table is imported from an external database). I need to be able to match the two tables up. Can anyone please suggest how to do this or even if this is possible.
Thanks
View 6 Replies
View Related
May 3, 2015
I have two tables with name of accone and the second with the name of acctwo. These two tables are same according to number of columns and also same according to data types and also same according to the column names just the data are difference and also one column (attribute) with the name of ID is same in both tables. Their is a primary key relationship (one-to-one) between these two IDs. I need a query that can combine the data of both of them and can be updated using query. I mean that data of first table and second table must become under one same column not two columns one for first table and second one for second tabel.
View 4 Replies
View Related
Feb 11, 2014
I have a table called MiscORders where all the orders are tracked. There is an ID, order number , other fields and ParentorderID fields in it. Whenever an order is modified they create a new order with ordernumber and have the previous order number as the parent. The next time it is amended or closed another order is created with the parent order attached. Here is some sample data
Order ID OrderNum Parent order id
1 MISC 2013-10
2 MISC 2013-10A MISC 2013-10
3 MISC 2013-10B MISC 2013-10
Now I am creating a query that shows the lifecycle of the order
MISC 2013-10 Issue and deadline date MISC 2013-10A issue and deadline date MISC 2013-10B issue and deadline date.I tried to create a query using self joins to the same table. SQL is attached
SELECT MISCORDER.OrderNum, MISCORDER.[Date Issued], MISCORDER.[Deadline Date], MISCORDER_1.OrderNum
FROM MISCORDER LEFT JOIN MISCORDER AS MISCORDER_1 ON MISCORDER.OrderNum = MISCORDER_1.RescindedOrderID
WHERE (((MISCORDER.OrderNum) Not Like '*A' And (MISCORDER.OrderNum) Not Like '*B' And (MISCORDER.OrderNum) Not Like '*C' And (MISCORDER.OrderNum) Not Like '*D') AND ((MISCORDER_1.OrderNum) Not Like '*B'));
How can I put a condition on the table to show only records with order num ending with A. It is not working if i use it in the where condition..
View 1 Replies
View Related
Apr 2, 2013
I have 4 queries in which data needs to be connected from the date and shown as a single date showing each sections entry in a row and a cumulative total is maintained as the balance .
See the attached image ...
View 7 Replies
View Related
Apr 15, 2015
I am trying to develop a query in MS Access 2010 to join two tables using three joins one of which is a (between) date range. The tables are contained in Access.
ABCPART links to XYZPART. ABCSERIAL links to XYZSERIAL. ABCDATE links to (between) XYZDATE1 and ZYZDATE2.
[ABCTABLE]
ABCORDER
ABCPART
[code]...
View 4 Replies
View Related
Nov 29, 2007
Can a Append Query move all my data stored in multiple tables to another database with a identical table structure?
Because as I try to work the query, I keep getting prompted to "Select a table" I want to append to, and I don't want to append to just one table...
View 4 Replies
View Related
Nov 21, 2014
I have a table that is basically a survey form. The same series of options was available for 35 questions, and the table used to have a text string written for each answer. Because of all the repetitive data, I created a second table that assigned a number value to each of the nine possible options in these 35 separate fields. What happened is that, instead of the same text strings repeated over and over (and taking up real estate), now each of the 35 columns had a single number in them.
Now comes the day of reckoning and TPTB want a query with the raw data and the original text strings back in instead of the numbers. I was thinking doing something along the lines of a DLookup, but I can't seem to make that work in a query correctly. Apart from calling the same table and linking it over and over to the different fields in the original data table (see photo for how insane that is).
View 2 Replies
View Related
Apr 12, 2013
I have 10 tables, 30+ fields on each table (every table has the same 'account number' field). I only need from 5 - 20 fields from each table. How do I get the certain fields from each table and put them in a table, query or report?
View 1 Replies
View Related
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
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
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
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
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
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
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
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
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
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