473,624 Members | 2,150 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

joining several tables

Hi,

I would like to get all the records from 9 tables that have the same
field value in one field (it is a unique field)that is shared by all the
tables. Would this
method of joining work:

select * from table 1, table 2, table 3 where table 1.com_field =
table 2.com_field and table 2.com_field = table 3.com_field

(I left off the rest of tables to keep this message small.)If not, how can I
do it?

thanks
James__________ _______________ _______________ _______________ ___________
james ICQ#: 4617005 Current ICQ status: + More ways to contact me i See more
about me: _______________ _______________ _______________ _______________ ______
Nov 12 '05 #1
3 4467

"james" <th*****@hotmai l.com> wrote in message
news:ZO******** *********@newsr ead4.news.pas.e arthlink.net...
Hi,

I would like to get all the records from 9 tables that have the same
field value in one field (it is a unique field)that is shared by all the
tables. Would this
method of joining work:

select * from table 1, table 2, table 3 where table 1.com_field =
table 2.com_field and table 2.com_field = table 3.com_field

(I left off the rest of tables to keep this message small.)If not, how can I do it?

thanks
James


Yes, I think that would work. I assume you would also have: where table
1.com_field = 'xxxxxxxx.' Also, be careful about select *. Try to only
select the columns you really need.

If the tables are all the same columns (don't have to be the same column
names) then you might try a UNION ALL with the same where clause in each
select. This would be more efficient.
Nov 12 '05 #2
"Mark A" <ma@switchboard .net> wrote in message news:<Bj******* ***********@new s.uswest.net>.. .
"james" <th*****@hotmai l.com> wrote in message
news:ZO******** *********@newsr ead4.news.pas.e arthlink.net...
Hi,

I would like to get all the records from 9 tables that have the same
field value in one field (it is a unique field)that is shared by all the
tables. Would this
method of joining work:

select * from table 1, table 2, table 3 where table 1.com_field =
table 2.com_field and table 2.com_field = table 3.com_field

(I left off the rest of tables to keep this message small.)If not, how can

I
do it?

thanks
James


Yes, I think that would work. I assume you would also have: where table
1.com_field = 'xxxxxxxx.' Also, be careful about select *. Try to only
select the columns you really need.

If the tables are all the same columns (don't have to be the same column
names) then you might try a UNION ALL with the same where clause in each
select. This would be more efficient.


be aware that the resultset (from the 2 above statements) will not be the same.

assume each table has 5 columns and 1000 rows (rows with the desired value).

select * from tab1, tab2, tab3 ... tab9 where .....
will give you a resultset with 1000 rows long and 9*5 columns wide.

tab1.c1 tab1.c2 tab1.c3 tab1.c4 tab1.c5 . . . . tab9.c5
------- ------- ------- ------- ------- -------
....
select * from tab1 where ....
UNION ALL
select * from tab2 where ....
....
....
UNION ALL
select * from tab9 where ....

will give you 9000 rows by 5 columns
reading your email, it's not clear - at least for me - which do you wanna
(maybe an example would help)

jörg
Nov 12 '05 #3
Thanks, and here is an example. What I am trying to do, is prove that all 9
tables with the same key fields have the same com_field value. The com_field
will be added to all the tables during a database conversion, it will be a
numeric field generated using DB2 Identity feature. The results I need to
see would look something like this:

table1.key field 1
table 1. key field 2
table 1. com_field

table2. key field 1
table 2 .key field 2
talbe 2 . com_field

table 3 .key field 1
table 3 .key field 2
table 3 . com_field

.....

All the field values would be identical. I don't need to see the results of
the entire query, several samples should do. Hope this makes it more
understandable!

James
Nov 12 '05 #4

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

Similar topics

4
4269
by: Job Lot | last post by:
Is there anyway of Joining two or more DataTable with similar structure? I have three DataTables with following structures Data, AmountB/F, Repayments, InterestCharged and AmountC/F i want to join these tables on the basis of Date. I don't want three rows for each date, i want the values to be added for similar dates. thanx
2
3501
by: James | last post by:
Can anyone please shed some light on the following... I have a framework that uses dynamically created tables, named using an incremental "attribute set ID", as follows: attrdata_1 attrdata_2 attrdata_3 etc, etc...
1
1915
by: Brian | last post by:
I need help joining info from two tables. Table1 and Table 2 have the same fields(Node,Card,Slot,Facility,Sub-Port,Channel,Group,Cic) Group is text, rest are number. Table 1 contains records for all possible combinations of Node,Card,Slot,Facility,Sub-Port,Channel which indicates a physical port on a piece of equipment. Table 2 is imported from a piece of equipment containing all above info that has an assigned Group and Cic. I want to...
3
1451
by: kevcar40 | last post by:
Hi i have several tables i need to join in someway the tables have the foloowing fields table 1 Dates fault1, fault2, fault3, area 27/5/05 broken bent straight A1 table 2 Dates fault4, fault5, fault6, area 27/5/05 broky benty straighty A2
3
9291
by: Reader | last post by:
Hello all, I am joining two tables in a query and the output should be all those records where two fields in table1 match two corresponding fields in table2. I joined the tables using both fields in design view and the Select statement in SQL view looks good. The query runs perfectly and shows the result I want but when I save the query and close it, re-opening in design view shows the error message "Microsoft Office Access can't
2
2596
by: nkechifesie | last post by:
I have created 9 tables in access via visdata and need to create another table joining all these tables. I have used the query in visdata to do this but it gives me an outrageous view. I have entered 2 records in each table but it gives me 65 records in the query. Please could you help me out. This is the code genreated by Visdata after I created the query, please what is wrong. the common field in 8 of the tables is Vehicle no and the common...
4
1555
by: Rnt6872 | last post by:
Table A Table B BOL# B_BOL# Chargeback# Hi All, I have been struggling with this for the past few months. I have two tables that I'm inner joining on BOL#=B_BOL#. This works fine. Now for the problem....When there are chargeback# fields associated with B_BOL# they aren't being captured as additional records. None of my tables
2
2253
by: Supermansteel | last post by:
I am joining these 2 tables together in Access 2003 and can't figure out the exact way of writing this script......Can anyone help? I have the following SQL: SELECT PL_Input.Date_ID,Count(PL_Input.+PL_Input.+PL_Input.+PL_Input.+PL_Input.) AS FROM Country INNER JOIN PL_Input ON Country.Country_ID = PL_Input.Country_ID WHERE (((. & "" & . & "" & . & "" & . & "" & .) Like "*2*"))
0
1705
bilibytes
by: bilibytes | last post by:
Hi there, I am wondering if there is a possibility to declare a Model_DbTable_Table1JoinedToTable2ToTable3... class It would be convenient to create compound table from several tables joined from a foreign key. Lets say we have: tables: -------------------------------------------
0
8173
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
8679
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
8621
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...
0
8475
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...
0
7159
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...
0
5563
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();...
1
2606
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
1
1785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1482
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.