Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / January 2005

Tip: Looking for answers? Try searching our database.

Three tables to one

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
EMW - 10 Jan 2005 20:55 GMT
Hi,

I have an Oracle database with different tables of data.
They all have one common field.
I need to combine some fields from three tables.
i.e.
field1 and field2 from table1
field3 and field4 from table2
field5 from table3

Alltogether I want to produce a dataset with one table with the following
schema: common, field1, field2, field3, field4, field5

How can I do this?
Can I do it by excecuting a SQL command to the database or do I combine the
data within the dataset or is there some other way of doing this?

My program is in VB.NET.

rg,
Eric
Marina - 10 Jan 2005 20:57 GMT
The most efficient way, would be to do joins in your SQL query, so this is
all done at the database level.

> Hi,
>
[quoted text clipped - 17 lines]
> rg,
> Eric
Peter Rilling - 10 Jan 2005 21:05 GMT
To expand, you can use a view to format the data appropriately and then all
the client has to do is select information from the view.

> The most efficient way, would be to do joins in your SQL query, so this is
> all done at the database level.
[quoted text clipped - 21 lines]
> > rg,
> > Eric
EMW - 10 Jan 2005 22:52 GMT
could you give me an example?
I've searched for some examples on joining tables, but couldn't get it to
work.

rg,
Eric

> The most efficient way, would be to do joins in your SQL query, so this is
> all done at the database level.
[quoted text clipped - 21 lines]
>> rg,
>> Eric
UAError - 11 Jan 2005 02:13 GMT
>could you give me an example?
>I've searched for some examples on joining tables, but couldn't get it to
>work.
>
>rg,
>Eric

Probably because you should have been looking for UNION
instead of JOIN, e.g.:

(
   SELECT commonA, field1, field2,
       'constA3', 'constA4', 'constA5'
       FROM tableA WHERE ...
)UNION(
   SELECT commonB, 'constB1', 'constB2',
       field3, field4, 'constB5'
       FROM tableB WHERE ...
)UNION(
   SELECT commonC, 'constC1', 'constC2',
       'constC3', 'constC4', field5
       FROM tableC WHERE ...
);

you could use UNION ALL to preserve duplicates between
SELECTs - but I don't think that applies here.
Note that the column value's data types (or the "constant"
replacements) in each of the SELECT's column positions need
to be compatible.

>> The most efficient way, would be to do joins in your SQL query, so this is
>> all done at the database level.
[quoted text clipped - 21 lines]
>>> rg,
>>> Eric
'Any fool can write code that a computer can understand.
Good programmers write code that humans can understand.'
Martin Fowler,
'Refactoring: improving the design of existing code', p.15
Cor Ligthert - 11 Jan 2005 08:26 GMT
I hate SQL so I always try too avoid it.

However being active in these newsgroups is every time learning more of it.

Eric, when this works, will you than answer that here, this can be a great
addition.

Cor

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.