473,623 Members | 3,345 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL-fu failing as I attempt to Update using multiple joins

11 New Member
G'day all,
I'm trying to update a single table (containing plans for flights) with information from the same and other tables (containing info for organisations and locations).

tblFlightPlans contains the txt-column 'TripSummary', which is what I'm trying to update, as well as ID numbers for the origin, destination, and plane carrier (eg, Qantas). The SQL code below successfully joins tblLocations and tblFlightPlans and updates TripSummary with a text name for the flight's origin.
Expand|Select|Wrap|Line Numbers
  1. UPDATE [SELECT PlaceID, PlaceName FROM tblLocations]. AS test INNER JOIN tblFlightPlans ON test.PlaceID=tblFlightPlans.Leg1Origin SET TripSummary = test.PlaceName;
  2.  
What I need is something very similar, but involving the above TWICE (two lookups), for an origin and a destination, as well as a carrier. I've tried this, which fails:
Expand|Select|Wrap|Line Numbers
  1. UPDATE 
  2. [SELECT PlaceID, PlaceName FROM tblLocations]. AS Origins INNER JOIN tblFlightPlans ON Origins.PlaceID=tblFlightPlans.Leg1Origin
  3. [SELECT PlaceID, PlaceName FROM tblLocations]. AS Destinations INNER JOIN tblFlightPlans ON Destinations.PlaceID=tblFlightPlans.Leg1Dest
  4. [SELECT OrgID, Name FROM tblOrganisations]. AS Carriars INNER JOIN tblFlightPlans ON Carriars.OrgID=tblFlightPlans.Leg1OrgID
  5.  
  6. SET TripSummary = Origins.PlaceName & " to " & Destinations.PlaceName & " by " Carriars.Name; 
  7.  
...and also this, which also fails (though again, the singular form works, if I'm only trying to update TripSummary with one PlaceName):
Expand|Select|Wrap|Line Numbers
  1. UPDATE tblFlightPlans 
  2. INNER JOIN [SELECT PlaceID, PlaceName FROM tblLocations]. AS Origins ON Origins.PlaceID=tblFlightPlans.Leg1Origin 
  3. INNER JOIN [SELECT PlaceID, PlaceName FROM tblLocations]. AS Destinations ON Destinations.PlaceID=tblFlightPlans.Leg1Dest
  4. INNER JOIN [SELECT OrgID, Name FROM tblOrganisations]. AS Carriars ON Carriars.OrgID=tblFlightPlans.Leg1OrgID
  5.  
  6. SET TripSummary = Origins.PlaceName & " to " & Destinations.PlaceName & " by " Carriars.Name; 
  7.  
What am I doing wrong? How do I approach using multiple joins in Access?

If all else fails, is there some sort of "append" function that will allow me to make 3 separate queries and tack it on to the same textbox?

Notes:
Interchanging "(xxx) AS x" and "[xxx]. AS x" gives the same errors, so I don't think it's a bracketing problem. Also, "Carriars" is deliberate, the name "Carriers" is already taken somewhere else =P
Mar 10 '09 #1
3 2263
modernshoggoth
11 New Member
UPDATE: Apparrently there is such a thing as 'nested INNER JOINs'. Looking into these now, but they're pretty obtuse beasts.
Mar 10 '09 #2
modernshoggoth
11 New Member
UPDATE: Nevermind, all, got it sorted! =)
The following does what I want, ie, gives a text output of "Location1 to Location2 by Carrier1".

Expand|Select|Wrap|Line Numbers
  1. UPDATE 
  2. [SELECT PlaceID, PlaceName FROM tblLocations]. AS Origins INNER JOIN 
  3. (
  4. [SELECT PlaceID, PlaceName FROM tblLocations]. AS Destinations INNER JOIN 
  5. (
  6. tblFlightPlans INNER JOIN [SELECT OrgID, Name FROM tblOrganisations]. AS Carriars ON Carriars.OrgID=tblFlightPlans.Leg1OrgID
  7. ON Destinations.PlaceID=tblFlightPlans.Leg1Dest
  8. ON Origins.PlaceID=tblFlightPlans.Leg1Origin 
  9.  
  10. SET TripSummary = Origins.PlaceName & " to " & Destinations.PlaceName & " by " & Carriars.Name;
  11.  
Mar 10 '09 #3
NeoPa
32,566 Recognized Expert Moderator MVP
Just to assuage your curiosity about the subquery notation, see Access QueryDefs Mis-save Subquery SQL.

Note, in most cases (except those where it seems Access recognises that it was created by itself) only the version with parentheses will be recognised.
Mar 11 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
12653
by: Peter | last post by:
I run most of my SQL scripts via kornshell on AIX. I use the "here-document" to run some of the smaller ones. Example: #!/bin/ksh # Analyze the table. sqlplus ${SCHEMA_NM}/${SCHEMA_PASSWD}@${DB_NM} <<-ANALYZE_TABLE SET TERMOUT ON
1
6615
by: Peter | last post by:
I've purchased VS.NET 2005 Standard and have tried to install SQL Server 2005 Express, but get the following error in the error log. Please could someone help me.... Microsoft SQL Server 2005 Express Edition x86: Component Microsoft SQL Server 2005 Express Edition x86 returned an unexpected value. ***EndOfSession***? Microsoft SQL Server 2005 Express Edition x86: Component Microsoft SQL Server 2005 Express Edition x86 returned an...
4
4279
by: Anns via SQLMonster.com | last post by:
My company currently has about 20-25 Ms Access Database that they want to replace the FE with .net and the BE on SQL. This will be done using Visual Studio 2005. Once the FE is converted to .net and the BE is SQL they all will be accessed through our intranet (sharepoint). I work in Ms Access and intermediate at VBA and just learing SQL through the ENTERPRISE MANAGER SCREEN.
6
2491
by: Fuzzydave | last post by:
I am back developing futher our Python/CGI based web application run by a Postgres DB and as per usual I am having some issues. It Involves a lot of Legacy code. All the actual SQL Querys are stored in the .py files and run in the .cgi files. I have the problem that I need to construct a row from two seprate SQL Querys, I have tried combining the two Querys but all that does is create a Query that returns nothing after a long period...
14
3019
by: Developer | last post by:
Hello All, i have recently installed VS2005 and was trying to install SQL sever 2000. I have Win XP' SP2. But when I tried installing, it only installed client tools and not the database. Can anyone please help me with this as I want to install SQL server and also wouold be grateful, if you can suggest me any workaround to dealwith this problem.(Like should I install any new OS etc). Any help would be appreciated.
11
6231
by: HC | last post by:
I posted this in one of the VB forums but I'm starting to think it might be more appropriate to have it here, since it really seems to be a SQL server (MSDE/Express 2005) problem: Hey, all, I have a problem with queries against a SQL server instance that I just found and is causing me fits. I hope someone can point me in the right direction, please. TIA. Basically, I got a Vista OS machine to test my VB6 app on it as some
3
6424
by: Steve | last post by:
Hi All I downloaded Sql server 2005 express SP2 and attempted to modify the Bootstrapper package files as I did with SP1 When i try to install SQL server as part of my VS 2005 deployment app I get an error at the end of the SQL server install phase 'Invalid endpoint'. (Note SQL server express gets installed OK) If I run SQL server express SP2 setup directly it I don't get the error
9
15135
by: fniles | last post by:
I would like to copy a table(s) from SQL Server 2005 to a CVS file and vice versa. I was thinking to use the BCP command line utility, but I have a few questions: 1. The machine where I am going to run BCP utility does not have SQL Server installed, so BCP.exe and its underlying DLLs are not there. I copied BCP.EXE, then it tells me that it expects sqlncli.dll. After I copied that DLL, it now says "Unable to load BCP resource DLL. BCP...
7
4045
by: Mike1961 | last post by:
Hi there. Well the situation is this, I have two tables: 1) tbl_registry where rows with code = 123 are 35 ; 1) tbl_Registered where rows with code = 123 are 43 In tbl_Registered I have it 7 rows more respect tbl_registry can you tell my why I have this situation:
2
11176
Frinavale
by: Frinavale | last post by:
SQL Injection Attack A database is a collection of information organised in such a way that allows computer programs to access data (even large amounts) quickly and easily. Data within a database is organised into tables, which contain records/rows of fields. A field contains the actual data used by the program. Relational Database Management Systems (RDBMS or sometimes just DBMS) allow users the ability to access and manipulate data within...
0
8221
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8162
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8662
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8463
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6104
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5560
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4067
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2593
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1468
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.