aspose file tools*
The moose likes JDBC and the fly likes Oracle Query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Oracle Query" Watch "Oracle Query" New topic
Author

Oracle Query

mash john
Greenhorn

Joined: Sep 04, 2005
Posts: 15
I have a parent table named Track_locations with org_roadmark and track_location_id as primary keys.

I have 2 child tables online_equip and unload_list_equip with track_location_id,org_roadmark as foreign keys.

I need to retrieve the total count of track_location_id present in both(or either of ) the child tables in a single query.
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3710
    
    5

Select the count of each using count(*) in the SQL query and then add the results which can also be done in the same SQL statement. Depending on your grouping requirements though, you might get duplicates (for example if the same parent reference appears in both child tables).

Again, your requirements would dictate how to proceed, but if you need the count to be for non-overlapping parents, the UNION command could also help.
[ December 19, 2005: Message edited by: Scott Selikoff ]

My Blog: Down Home Country Coding with Scott Selikoff
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Oracle Query