| .NET DotNet Forum Index » ADO .NET Forum » Parent/Child dataset select... |
|
Page 1 of 1 |
|
| Author |
Message |
| Midtown2oo3... |
Posted: Fri Oct 16, 2009 4:52 am |
|
|
|
Guest
|
Parent table
--------------------
Key
Count
Name
Type
Child table
--------------------
Key
ParentKey
Account
Department
"ParentKey" is a foreign key between the two tables.
I would like to perform a select as such: ChildTable.Select
([Department] = 'Dept1' AND Parent.[Type] = 'Public')
Is this even a possibility?
Thanks in advance. |
|
|
| Back to top |
|
|
|
| Nathan Sokalski... |
Posted: Sun Oct 18, 2009 12:51 am |
|
|
|
Guest
|
First of all, what do you want the result to be? Second, it sounds like you
should be looking at a newsgroup for SQL, possibly one of the
microsoft.public.sqlserver newsgroups.
--
Nathan Sokalski
njsokalski at (no spam) hotmail.com
http://www.nathansokalski.com/
"Midtown2oo3" <midtown2oo3 at (no spam) yahoo.com> wrote in message
news:a708a115-4428-403e-a4f7-05cf2924ce44 at (no spam) p4g2000yqm.googlegroups.com...
Quote: Parent table
--------------------
Key
Count
Name
Type
Child table
--------------------
Key
ParentKey
Account
Department
"ParentKey" is a foreign key between the two tables.
I would like to perform a select as such: ChildTable.Select
([Department] = 'Dept1' AND Parent.[Type] = 'Public')
Is this even a possibility?
Thanks in advance. |
|
|
| Back to top |
|
|
|
| Gregory A. Beamer... |
Posted: Mon Oct 19, 2009 12:15 pm |
|
|
|
Guest
|
Midtown2oo3 <midtown2oo3 at (no spam) yahoo.com> wrote in news:a708a115-4428-403e-
a4f7-05cf2924ce44 at (no spam) p4g2000yqm.googlegroups.com:
Quote:
Child table
--------------------
Key
ParentKey
Account
Department
"ParentKey" is a foreign key between the two tables.
I would like to perform a select as such: ChildTable.Select
([Department] = 'Dept1' AND Parent.[Type] = 'Public')
Is this even a possibility?
From a SQL standpoint? Very easy:
SELECT Child.*
FROM Child c
JOIN Parent p
ON c.ParentKey = p.Key
WHERE c.Department = at (no spam) Dept
AND p.Type = at (no spam) Type
From a DataSet, Entity or LINQ to SQL. Also easy enough, once you have
the model with both items. It still follows the basic idea shown in the
SQL query above.
Peace and Grace,
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
Twitter: at (no spam) gbworld
Blog: http://gregorybeamer.spaces.live.com
*******************************************
| Think outside the box! |
******************************************* |
|
|
| Back to top |
|
|
|
|