By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,722 Members | 1,247 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,722 IT Pros & Developers. It's quick & easy.

Counting Rows

P: n/a
Hi there,

I have an admin system (Add/Modify/Delete) for two types of records in the
database. They have a Parent - Child relationship

My problem is that I want to display on the "parent" record whether the
child exists or not .

The records are found in two different tables, but have the same Primary
Key.

Any ideas

cheers

Steven
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Steven wrote:
I have an admin system (Add/Modify/Delete) for two types of records in the
database. They have a Parent - Child relationship

My problem is that I want to display on the "parent" record whether the
child exists or not .

The records are found in two different tables, but have the same Primary
Key.


You'll be wanting to use a LEFT JOIN then. With a left join you can show all
the results from the first table whether or not there is a related record
from the second/joined table. The columns that would have been displayed
from the second table will all be NULL.

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Jul 17 '05 #2

P: n/a
Steven wrote:
Hi there,

I have an admin system (Add/Modify/Delete) for two types of records in the
database. They have a Parent - Child relationship

My problem is that I want to display on the "parent" record whether the
child exists or not .

Left Join. If you select [stuff] from table 1 left join table 2 on [stuff]
then every record in table 1 will appear ; if there aren't child record(s)
in table 2 for table 1 then the corresponding field will be null.
The records are found in two different tables, but have the same Primary
Key.


I don't think you mean this :) they'll have different primary keys but a
foreign key in the child .
Jul 17 '05 #3

P: n/a

"Paul Robson" <au******@autismuk.muralichucks.freeserve.co.uk> wrote in
message news:ck**********@newsg3.svr.pol.co.uk...
Steven wrote:
Hi there,

I have an admin system (Add/Modify/Delete) for two types of records in
the
database. They have a Parent - Child relationship

My problem is that I want to display on the "parent" record whether the
child exists or not .


Left Join. If you select [stuff] from table 1 left join table 2 on [stuff]
then every record in table 1 will appear ; if there aren't child record(s)
in table 2 for table 1 then the corresponding field will be null.
The records are found in two different tables, but have the same Primary
Key.


I don't think you mean this :) they'll have different primary keys but a
foreign key in the child .


It is possible for the primary key on the child table to be exactly the same
as the foreign key which links to the parent table. This is the way to
enforce a one-to-one relationship. If the child table has a different
primary key it will allow a one-to-many relationship which may not be
desirable.

--
Tony Marston

http://www.tonymarston.net

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.