Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
0 or More Children recs. but need SQL for NULL or first
Message
From
19/03/2007 03:51:12
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01205365
Message ID:
01205383
Views:
11
>Hi all
>
>I have parent-child tables. The child table can have 0 or more records for each parent record.
>
>I need to write an SQL where in each row I get a parent record and an either a NULL fields for the child table or only these 1st child record (no multiple occurrence of the parent record due to multiple child recs.), for each and every parent record.
>
>Please let me know how I can go about this.
SELECT *
 , (select top 1 field from child WHERE fk_Parent=Parent.pk order by fk_Parent) as child_field 
   FROM Parent
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform