473,748 Members | 2,551 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Conerting MS Access query to SQL

1 New Member
Hello,

I am trying to convert the following Access query to SQL. I am not sure about the multiple INNER JOINS. Can you help please?

SELECT dbo_ManagedRela tionshipBooks.S hortAlias AS Account, dbo_Portfolios. PortfolioID, dbo_Portfolios. ProductID, dbo_MainManaged Relationships.I sTaxAware INTO Portfolios
FROM (dbo_GO_Product s INNER JOIN ((((dbo_Managed RelationshipBoo ks INNER JOIN dbo_Relationshi pPortfolioMix ON dbo_ManagedRela tionshipBooks.R elationshipID = dbo_Relationshi pPortfolioMix.R elationshipID) INNER JOIN dbo_PortfolioAc countMix ON dbo_Relationshi pPortfolioMix.P ortfolioID = dbo_PortfolioAc countMix.Portfo lioID) INNER JOIN dbo_Portfolios ON dbo_Relationshi pPortfolioMix.P ortfolioID = dbo_Portfolios. PortfolioID) INNER JOIN dbo_Accounts ON dbo_PortfolioAc countMix.Accoun tID = dbo_Accounts.Ac countID) ON dbo_GO_Products .ProductID = dbo_Portfolios. ProductID) INNER JOIN dbo_MainManaged Relationships ON dbo_ManagedRela tionshipBooks.M ainRelationship ID = dbo_MainManaged Relationships.R elationshipID
WHERE (((dbo_GO_Produ cts.ParentProdu ctID) In (10029,10030,11 026)) AND ((dbo_ManagedRe lationshipBooks .Status)=1))
ORDER BY dbo_ManagedRela tionshipBooks.S hortAlias;


The SQL query would be:

SELECT Account = ManagedRelation shipBooks.Short Alias
, dbo_Portfolios. PortfolioID
, Portfolios.Prod uctID
, MainManagedRela tionships.IsTax Aware
INTO #Portfolios
FROM GO_Products
INNER JOIN ManagedRelation shipBooks
ON
(INNER JOIN dbo_Relationshi pPortfolioMix
ON ManagedRelation shipBooks.Relat ionshipID = RelationshipPor tfolioMix.Relat ionshipID
INNER JOIN PortfolioAccoun tMix
ON RelationshipPor tfolioMix.Portf olioID = PortfolioAccoun tMix.PortfolioI D
INNER JOIN Portfolios
ON RelationshipPor tfolioMix.Portf olioID = Portfolios.Port folioID
INNER JOIN Accounts
ON PortfolioAccoun tMix.AccountID = Accounts.Accoun tID,
ON GO_Products.Pro ductID = Portfolios.Prod uctID
INNER JOIN MainManagedRela tionships
ON ManagedRelation shipBooks.MainR elationshipID = MainManagedRela tionships.Relat ionshipID)
WHERE GO_Products.Par entProductID In (10029,10030,11 026)
AND ManagedRelation shipBooks.Statu s=1
ORDER BY ManagedRelation shipBooks.Short Alias


Thanks sqlnew123
Mar 12 '07 #1
1 1343
dorinbogdan
839 Recognized Expert Contributor
Expand|Select|Wrap|Line Numbers
  1. SELECT ManagedRelationshipBooks.ShortAlias as Account, dbo_Portfolios.PortfolioID, Portfolios.ProductID, MainManagedRelationships.IsTaxAware 
  2. INTO #Portfolios
  3. FROM (GO_Products 
  4. INNER JOIN 
  5. ((((ManagedRelationshipBooks 
  6. INNER JOIN RelationshipPortfolioMix ON ManagedRelationshipBooks.RelationshipID = RelationshipPortfolioMix.RelationshipID) 
  7. INNER JOIN PortfolioAccountMix ON RelationshipPortfolioMix.PortfolioID = PortfolioAccountMix.PortfolioID) 
  8. INNER JOIN Portfolios ON RelationshipPortfolioMix.PortfolioID = Portfolios.PortfolioID) 
  9. INNER JOIN Accounts ON PortfolioAccountMix.AccountID = Accounts.AccountID) 
  10. ON GO_Products.ProductID = Portfolios.ProductID) 
  11. INNER JOIN MainManagedRelationships ON ManagedRelationshipBooks.MainRelationshipID = MainManagedRelationships.RelationshipID
  12. WHERE GO_Products.ParentProductID In (10029,10030,11026)
  13. AND ManagedRelationshipBooks.Status=1
  14. ORDER BY ManagedRelationshipBooks.ShortAlias
Mar 13 '07 #2

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

Similar topics

14
5418
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB 7.2 environment, the choices the optimizer makes often seem flaky. But this last example really floored me. I was hoping someone could explain why I get worse response time when the optimizer uses two indexes, than when it uses one. Some context:
4
2054
by: bhbgroup | last post by:
I have a query on one large table. I only add one condition, i.e. a date (the SQL reads like 'where date > parameterdate'. This query is rather quick if 'parameterdate' is either explicitly written into the query or if it is a 'normal' access parameter value that is entered during the query. If I however create a separate parameter table that contains nothing but the date I want to use in the query and then refer to this table (the query...
52
9980
by: Neil | last post by:
We are running an Access 2000 MDB with a SQL 7 back end. Our network guy is upgrading to Windows Server 2003 and wants to upgrade Office and SQL Server at the same time. We're moving to SQL Server 2005, and, since he already has licenses for Office Pro 2002, he wants to upgrade to that. I've been saying that we need to upgrade to Access 2003, not 2002, even if Office is kept at 2002. We are also looking to do a fair amount of...
4
3095
by: tt40 | last post by:
Anyone know how to prevent Access 2002 from automatically breaking all the incorrect joins in a query and then automatically saving the broken query? This is what I would call stupid design behaviour...Access takes your 'broken' query and auto saves it as what I call a 'corrupt' query... 1. Rename some BE tables and attributes 2. Open your FE 3. Open a query in design view that you know to now have broken names
6
5477
by: InnoCreate | last post by:
Hi everyone. I've recently written a classic asp website which uses an MS Access datasource. I know this is less than an ideal data source as it has limited functionality. I have a search form on my website which allows users to define parameters and return results accordingly. The problem i have is a need to return these results in a random order each time. With SQLServer i know NEWID() would do the trick - used this many times before...
3
7772
by: mnjkahn via AccessMonster.com | last post by:
I'm running Access 2003, modifying a query that has over 45 fields. When I right click on the field name in Query Design View, and then click Build, Access crashes before the Build window appears. It doesn't happen every time, and using the Zoom window works fine. It appears that it only happens when I want to modify an existing expression. This continues to happen even after the database is repaired and reopened. Anyone have any...
6
4404
by: jsacrey | last post by:
Hey everybody, got a secnario for ya that I need a bit of help with. Access 97 using linked tables from an SQL Server 2000 machine. I've created a simple query using two tables joined by one field between them. The join field in both tables are indexed and I'm selecting 1 field from each table to lookup. The Access query is taking more than 60 second to retrieve 1 record and if I execute the same query within the Query Analyzer, it...
2
9840
by: existential.philosophy | last post by:
This is a new problem for me: I have some queries that open very slowly in design view. My benchmark query takes about 20 minutes to open in design view. That same query takes about 20 minutes to open in datasheet view. As an experiment, I deleted all rows in all tables; after that, the query took only seconds to open in both design view and datasheet view. From these facts, I conclude that Access is evaluating the query when I go to...
9
3634
by: Sinner | last post by:
Hi, I have a field name 'USER' in tableMAIN. How do I replace the user names with corresponding user names. I can do that in xl using vlookup but now I'm trying to find a way to do that in access. For a user mismatch, it should give NA Thx.
0
8832
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
9562
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
9386
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6799
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
6078
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
4608
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...
3
2217
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.