Saturday, February 25, 2012

Master-Detail (2 details)

Hi!
I have the following master-destails table in my database:
www.virtuasoft.com.br/help.JPG
Please help in the following sqls:
1. How can i create a SQL that returns all the field from both tables? (i
have tried INNER JOIN, but, since Person and Company have different fields,
it doesnt work)
2. How can i create a SQL search both tables for all fields and add a column
telling which table it got the records form (
something like: SELECT *, 'Client' As Type FROM Client INNER JOIN
Person ON Client.PKid = Person.PKid
SELECT *, 'Company' As Type FROM Company
INNER JOIN Person ON Company.PKid = Person.PKid
)
Thanks a lot, Im having a really hard time trying to do it!
Bruno NOn Sat, 26 Feb 2005 16:12:04 -0300, Bruno N wrote:

>Hi!
>I have the following master-destails table in my database:
>www.virtuasoft.com.br/help.JPG
>Please help in the following sqls:
(snip)
Hi Bruno,
Has someone already answered your questions? I don't see any replies,
even though your post is already two days old, but maybe my newsreader
missed some messages?
Annyway, I don't really understand your data and requested output. I
think I'd understand better if you post the CREATE TABLE statements to
create your tables on my system, the INSERT statements to fill them with
some sample data and the output you'd like to get, based on that sample
data. Check out www.aspfaq.com/5006 for more info on how to present your
problem.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)|||Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, datatypes, etc. in your
schema are. Sample data is also a good idea, along with clear
specifications. Most of us will not jump to a URL provided by a
stranger. And most of us would rather work with DDL instead of a .jpg.|||"Hugo Kornelis" <hugo@.pe_NO_rFact.in_SPAM_fo> wrote in message
news:v44721h7dkd7u38on929be9sjhe576uq2h@.
4ax.com...
> Has someone already answered your questions? I don't see any replies,
> even though your post is already two days old, but maybe my newsreader
> missed some messages?
No, this was posted on the 28th but it seems that the poster has a clock
problem.

No comments:

Post a Comment