473,837 Members | 1,758 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

5 tables need help with LEFT JOIN SQL!!

Hi all,

I am working with a computer hardware asset database and I am trying to get
information out of it for each PC in my organisation.

Here is the basic table structure:

Table1 -> Table2 -> Table3
-> Table4 -> Table5

Table1 is the master, table2 and table4 a linking tables to table3 and
table5

This is what I am trying to do:

select table1.name, table3.TotalVis ibleMemory, table5.label from (LEFT JOINS
HERE)

I have successfully retrieved the information from table 3 using this SQL:

select table1.name, table3.TotalVis ibleMemorySize
from
(table1 LEFT OUTER JOIN table2 ON (table1.id$=tab le2.GroupCompon ent))
LEFT OUTER JOIN table3 ON (table2.PartCom ponent=table3.i d$)
order by table1.name;

NOW, if I wanted to add a field table5.label how would I add the 2 LEFT
OUTER statements to this SQL?

I hope someone can help.

Thanks,

Vypre

Jul 20 '05 #1
1 6931
Justin Hennessy wrote:
select table1.name, table3.TotalVis ibleMemorySize
from
(table1 LEFT OUTER JOIN table2 ON (table1.id$=tab le2.GroupCompon ent))
LEFT OUTER JOIN table3 ON (table2.PartCom ponent=table3.i d$)
order by table1.name;

NOW, if I wanted to add a field table5.label how would I add the 2 LEFT
OUTER statements to this SQL?


I'm not sure why you're using an outer join between the linking table
and table3.

I'd try writing the query in the following way:

SELECT table1.name, table3.TotalVis ibleMemorySize, table5.label
FROM table1 LEFT OUTER JOIN
(table2 INNER JOIN table3 ON table2.PartComp onent = table3.id$)
ON table1.id$ = table2.GroupCom ponent
LEFT OUTER JOIN
(table4 INNER JOIN table5 ON table4.someFiel d = table5.id$)
ON table1.id$ = table4.someOthe rField
ORDER BY table1.name

Of course, replace someField and someOtherField with the actual fields
in table4 that you use to link to table1 and table5.

Regards,
Bill K.
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1780
by: R. Tarazi | last post by:
Hello, DB-structure: ========= firmendaten ----------------- firmendatenid <- firmennummer name strasse
1
5642
by: Eric | last post by:
Hi Folks, Lets assume I have three tables. Their layout is as follows. Please note that tblPeople does not have an entry for Denver (this is my problem) tblCity _________________ CityName OCID LA 1 Denver 2
6
2578
by: Allan | last post by:
Please help, below is my problem. Let's say I have 2 tables, a Products table and a Colors table that go as follow: Table Products prodID Name 1 shirt 2 tshirt
7
9353
by: deko | last post by:
SELECT tblTxAcct.TxAcctName, tblTxType.TxTypeName, Nz(qryTxAcctListCt.TxCount, 0) AS TxCt FROM (tblTxAcct INNER JOIN tblTxType ON tblTxAcct.TxType_ID=tblTxType.TxType_ID) LEFT JOIN qryTxAcctListCt ON tblTxAcct.TxAcct_ID=qryTxAcctListCt.TxAcct_ID; I use this query as a RecordSource for a Datasheet that displays Accounts, Types, and the number of Transactions in each Account. An Account cannot exist outside of a Type, but an Account...
5
3360
by: man7 | last post by:
Hi Im having problems migrating a query from Oracle to MS Access..after much modification i arrived at this query: SELECT t4.org_nm, t1.run_id, t3.org_id, t1.Plan_Yr_n, t2.plan_id, t3.Opt_Out_i, (IIf(t3.Prod_ty_c="EPO","HMO",t3.Prod_ty_c)) as Product, t3.bus_ln_c, t3.FUND_TY_C, t2.orig_plan_c, t2.orig_plan_nm FROM (((BENEXCH_T_RIBT_BTCH t1
2
1340
by: eurolinux | last post by:
I'm trying to left join a table where there are two identical fields I want to select all records in a field from the left table and only those records from the identical field of the right table which are not bigger or smaller then 1 both field in the tables are integer data type Can someone help
0
1208
by: sixtus | last post by:
I need a little help. I have 3 Mysql tables: Week (with columns day and hour) Activity (with columns day, hour, activityid and ac_text) Person (with columns name and activityid) I would like to create a scheme showing the activities during a week sorted on days and hours. If I ignore the person table I can fix it with the statement: Select …. From week left join activity on (week.day = activity.day) and (week.hour = activity.hour)...
9
1747
by: chadlupkes | last post by:
I'm getting NULLs where there shouldn't be. Any help is appreciated. Here are the tables: precinct Field Type Null Key Default Extra id smallint(6) PRI NULL auto_increment precinct_number int(11) 0 precinct_name varchar(20) MUL
1
4043
by: naveenchhibber | last post by:
Hi all pls tell me that the following statment is valid in oracle 9i or 10g.. update ws set received_by_facility = coalesce(rbf_ouk.organizational_unit_id, 0), assigned_to_facility = coalesce(atf_ouk.organizational_unit_id, 0), received_by_team = coalesce(rbt_ouk.organizational_unit_id, 0), assigned_to_team = coalesce(att_ouk.organizational_unit_id, 0)
0
9685
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
10886
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...
1
10634
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
9413
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
7817
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
7007
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
5853
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4052
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3126
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.