Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How would I write such query? this even possible?

Status
Not open for further replies.

rudyten

Programmer
Oct 22, 2002
6
US
Parent table has a type indicator field(There are 5
possible values "1", "2"..."5") (note: indicator field is part of primary key)
Value "1" is for Child_table_personal (has comment Field)
Value "2" is for Child_table_commercial (has comment Field)
Value "3" - "5" ignore these

Parent table has 50 records
Child_table_personal has 20 records
Child_table_commercial has 30 records
=======================================
is the a way to create for me to create a query that will bring back all 50 record to display comment field?

Comment field are located in child tables.
 
In Oracle I would write something like

select comment from parent_table, childtable_personal where type = '1' and childtable_personal.Parent_ID = parent_table.ID
union all
select comment from parent_table, childtable_commercial where type = '2' and childtable_commercial.Parent_ID = parent_table.ID

all the results look to be in a single column, even though they have different sources If you want them 'in order' you can leave the 'all' out and it will sort them I tried to remain child-like, all I acheived was childish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top