PC Review


Reply
Thread Tools Rate Thread

Combining 3 tables

 
 
Tim
Guest
Posts: n/a
 
      23rd Dec 2006
I have two tables, and one giving extra information about this
combination.

When I use the query "SELECT * FROM TableA,TableB" I get the desired
records, but I want to ignore the records that already exist in TableC
and show a specific column of TableC instead otherwise empty.

I've been trying subqueries and joins for a few days now to get the
desired result, but nothing will give me what I'm looking for. Maybe my
knowlegde on SQL is too limited, so please enlight me...

TableA
-----------
1 - First A
2 - Second A
3 - Third A

TableB
----------
1 - First B
2 - Second B
3 - Third B

TableC
----------
1 - 1 - 1 - FirstAFirstB
2 - 1 - 3 - FirstAThirdB


With the basic query I would get

1 - First A - 1 - First B - empty
1 - First A - 2 - Second B - empty
1 - First A - 3 - Third B - empty

2 - Second A - 1 - First B - empty
2 - Second A - 2 - Second B - empty
2 - Second A - 3 - Third B - empty

3 - Third A - 1 - First B - empty
3 - Third A - 2 - Second B - empty
3 - Third A - 3 - Third B - empty

What I want to become is

1 - First A - 1 - First B - FirstAFirstB
1 - First A - 2 - Second B - empty
1 - First A - 3 - Third B - FirstAThirdB

2 - Second A - 1 - First B - empty
2 - Second A - 2 - Second B - empty
2 - Second A - 3 - Third B - empty

3 - Third A - 1 - First B - empty
3 - Third A - 2 - Second B - empty
3 - Third A - 3 - Third B - empty

Many thanks in advance!

 
Reply With Quote
 
 
 
 
Joseph Meehan
Guest
Posts: n/a
 
      24th Dec 2006
Tim wrote:
> I have two tables, and one giving extra information about this
> combination.
>
> When I use the query "SELECT * FROM TableA,TableB" I get the desired
> records, but I want to ignore the records that already exist in TableC
> and show a specific column of TableC instead otherwise empty.
>
> I've been trying subqueries and joins for a few days now to get the
> desired result, but nothing will give me what I'm looking for. Maybe
> my knowlegde on SQL is too limited, so please enlight me...
>
> TableA
> -----------
> 1 - First A
> 2 - Second A
> 3 - Third A
>
> TableB
> ----------
> 1 - First B
> 2 - Second B
> 3 - Third B
>
> TableC
> ----------
> 1 - 1 - 1 - FirstAFirstB
> 2 - 1 - 3 - FirstAThirdB
>
>
> With the basic query I would get
>
> 1 - First A - 1 - First B - empty
> 1 - First A - 2 - Second B - empty
> 1 - First A - 3 - Third B - empty
>
> 2 - Second A - 1 - First B - empty
> 2 - Second A - 2 - Second B - empty
> 2 - Second A - 3 - Third B - empty
>
> 3 - Third A - 1 - First B - empty
> 3 - Third A - 2 - Second B - empty
> 3 - Third A - 3 - Third B - empty
>
> What I want to become is
>
> 1 - First A - 1 - First B - FirstAFirstB
> 1 - First A - 2 - Second B - empty
> 1 - First A - 3 - Third B - FirstAThirdB
>
> 2 - Second A - 1 - First B - empty
> 2 - Second A - 2 - Second B - empty
> 2 - Second A - 3 - Third B - empty
>
> 3 - Third A - 1 - First B - empty
> 3 - Third A - 2 - Second B - empty
> 3 - Third A - 3 - Third B - empty
>
> Many thanks in advance!


Is there any relationship between the data in the tables?

--
Joseph Meehan

Dia 's Muire duit



 
Reply With Quote
 
Tim
Guest
Posts: n/a
 
      24th Dec 2006
Only in the third table, which holds an identifier for each the two
first tables...


Joseph Meehan schreef:

> Tim wrote:
> > I have two tables, and one giving extra information about this
> > combination.
> >
> > When I use the query "SELECT * FROM TableA,TableB" I get the desired
> > records, but I want to ignore the records that already exist in TableC
> > and show a specific column of TableC instead otherwise empty.
> >
> > I've been trying subqueries and joins for a few days now to get the
> > desired result, but nothing will give me what I'm looking for. Maybe
> > my knowlegde on SQL is too limited, so please enlight me...
> >
> > TableA
> > -----------
> > 1 - First A
> > 2 - Second A
> > 3 - Third A
> >
> > TableB
> > ----------
> > 1 - First B
> > 2 - Second B
> > 3 - Third B
> >
> > TableC
> > ----------
> > 1 - 1 - 1 - FirstAFirstB
> > 2 - 1 - 3 - FirstAThirdB
> >
> >
> > With the basic query I would get
> >
> > 1 - First A - 1 - First B - empty
> > 1 - First A - 2 - Second B - empty
> > 1 - First A - 3 - Third B - empty
> >
> > 2 - Second A - 1 - First B - empty
> > 2 - Second A - 2 - Second B - empty
> > 2 - Second A - 3 - Third B - empty
> >
> > 3 - Third A - 1 - First B - empty
> > 3 - Third A - 2 - Second B - empty
> > 3 - Third A - 3 - Third B - empty
> >
> > What I want to become is
> >
> > 1 - First A - 1 - First B - FirstAFirstB
> > 1 - First A - 2 - Second B - empty
> > 1 - First A - 3 - Third B - FirstAThirdB
> >
> > 2 - Second A - 1 - First B - empty
> > 2 - Second A - 2 - Second B - empty
> > 2 - Second A - 3 - Third B - empty
> >
> > 3 - Third A - 1 - First B - empty
> > 3 - Third A - 2 - Second B - empty
> > 3 - Third A - 3 - Third B - empty
> >
> > Many thanks in advance!

>
> Is there any relationship between the data in the tables?
>
> --
> Joseph Meehan
>
> Dia 's Muire duit


 
Reply With Quote
 
Joseph Meehan
Guest
Posts: n/a
 
      10th Jan 2007
Tim wrote:
> Only in the third table, which holds an identifier for each the two
> first tables...


IF (that's a big if) I understand this right, I can't see how you can do
what you want without setting up a relationship to the third table.


>
>
> Joseph Meehan schreef:
>
>> Tim wrote:
>>> I have two tables, and one giving extra information about this
>>> combination.
>>>
>>> When I use the query "SELECT * FROM TableA,TableB" I get the desired
>>> records, but I want to ignore the records that already exist in
>>> TableC and show a specific column of TableC instead otherwise empty.
>>>
>>> I've been trying subqueries and joins for a few days now to get the
>>> desired result, but nothing will give me what I'm looking for. Maybe
>>> my knowlegde on SQL is too limited, so please enlight me...
>>>
>>> TableA
>>> -----------
>>> 1 - First A
>>> 2 - Second A
>>> 3 - Third A
>>>
>>> TableB
>>> ----------
>>> 1 - First B
>>> 2 - Second B
>>> 3 - Third B
>>>
>>> TableC
>>> ----------
>>> 1 - 1 - 1 - FirstAFirstB
>>> 2 - 1 - 3 - FirstAThirdB
>>>
>>>
>>> With the basic query I would get
>>>
>>> 1 - First A - 1 - First B - empty
>>> 1 - First A - 2 - Second B - empty
>>> 1 - First A - 3 - Third B - empty
>>>
>>> 2 - Second A - 1 - First B - empty
>>> 2 - Second A - 2 - Second B - empty
>>> 2 - Second A - 3 - Third B - empty
>>>
>>> 3 - Third A - 1 - First B - empty
>>> 3 - Third A - 2 - Second B - empty
>>> 3 - Third A - 3 - Third B - empty
>>>
>>> What I want to become is
>>>
>>> 1 - First A - 1 - First B - FirstAFirstB
>>> 1 - First A - 2 - Second B - empty
>>> 1 - First A - 3 - Third B - FirstAThirdB
>>>
>>> 2 - Second A - 1 - First B - empty
>>> 2 - Second A - 2 - Second B - empty
>>> 2 - Second A - 3 - Third B - empty
>>>
>>> 3 - Third A - 1 - First B - empty
>>> 3 - Third A - 2 - Second B - empty
>>> 3 - Third A - 3 - Third B - empty
>>>
>>> Many thanks in advance!

>>
>> Is there any relationship between the data in the tables?
>>
>> --
>> Joseph Meehan
>>
>> Dia 's Muire duit


--
Joseph Meehan

Dia 's Muire duit



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining Tables KAitchison Microsoft Access Queries 2 25th Sep 2009 08:23 PM
combining tables jlute@marzetti.com Microsoft Access Queries 4 26th Aug 2008 03:06 PM
Combining tables =?Utf-8?B?Sm9oblc=?= Microsoft Access Queries 3 6th Feb 2007 03:37 PM
RE: Combining Tables =?Utf-8?B?VG9tIFdpY2tlcmF0aA==?= Microsoft Access 1 31st Dec 2005 09:29 PM
Combining tables =?Utf-8?B?SmltbXlD?= Microsoft Access External Data 7 1st Jul 2004 01:32 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:32 PM.