473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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.TotalVisibleMemory, table5.label from (LEFT JOINS
HERE)

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

select table1.name, table3.TotalVisibleMemorySize
from
(table1 LEFT OUTER JOIN table2 ON (table1.id$=table2.GroupComponent))
LEFT OUTER JOIN table3 ON (table2.PartComponent=table3.id$)
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 6893
Justin Hennessy wrote:
select table1.name, table3.TotalVisibleMemorySize
from
(table1 LEFT OUTER JOIN table2 ON (table1.id$=table2.GroupComponent))
LEFT OUTER JOIN table3 ON (table2.PartComponent=table3.id$)
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.TotalVisibleMemorySize, table5.label
FROM table1 LEFT OUTER JOIN
(table2 INNER JOIN table3 ON table2.PartComponent = table3.id$)
ON table1.id$ = table2.GroupComponent
LEFT OUTER JOIN
(table4 INNER JOIN table5 ON table4.someField = table5.id$)
ON table1.id$ = table4.someOtherField
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
by: R. Tarazi | last post by:
Hello, DB-structure: ========= firmendaten ----------------- firmendatenid <- firmennummer name strasse
1
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 ...
6
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
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...
5
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,...
2
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...
0
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...
9
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...
1
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), ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...

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.