|
 |
sql_language thread: Is it possible in SQL?
Message #1 by "Ali" <ali1350@u...> on Thu, 29 Mar 2001 18:02:46
|
|
Not with pure SQL. If you are using ADO on the client you build a Hierarchical
recordset where there's one row from T1 and a then one of the columns in the T1 row
is actually a "child" recordset that contains all the rows from T2. The sytanx is a
little goofy and a little restrictive. problems can arise when you want to use
stored procs as the recordset sources. the MSDN has some docs on this. the
techinique is known as "Data Shaping".
hope this helps,
john
--- Ali <ali1350@u...> wrote:
> Hi all,
>
> Here is my question: (I'm not sure it is possilbe or not)
>
> I have two tables in my database and it called T1 and T2.
>
> The specs for each tables are:
>
> T1 columns:
>
> T1_ID (Primary Key)
> T1_F1
>
> T2 Columns:
>
> T2_ID (PK)
> T2_T1_ID (FK)
> T2_F3
>
> There is "One to Many" relation between T1 and T2 with "T1_ID" as
> PK and "T2_T1_ID" as FK.
>
> I assume for each row in "T1" we have fix numbers of rows on "T2" for
> example let's suppose for each row on "T1" we only have 3 rows related to
> that on "T2"
>
> I was wondering is there anyway to get a query that give me the following
> result:
>
> One row in "T1" and one column on "T2", but instead of get result in three
> different rows, I would like to have only one row for each joint, like this
>
>
> T1_ID
> T1_F1
> T2_F3 (For the first row on "T2" with same FK as "T1_ID")
> T2_F3 (For the second row on "T2" with same FK as "T1_ID")
> T2_F3 (For the third row on "T2" with same FK as "T1_ID")
>
>
> Thank,
> Ali Hosseinian
>
>
=====
----------------------------
John Pirkey
MCSD
John@S...
http://www.stlvbug.org
__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/?.refer=text
|
|
 |