Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select all question
Message
From
15/09/2006 14:12:18
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01154181
Message ID:
01154228
Views:
9
>Reposted for clarity:
>
>Hi,
>
>Can I do the following with a select all type statment"
>
>I have a table that looks something like this:
>
>
>r# household Parent house# ages
>1  Smiths    Robert 27 42
>2            Bobby  27  4 && child of Robert
>3  Barnes    Mary   74 32
>4            Margy  74  2 && child of Mary
>etc.
>
>
>Can I use an SQL statement to generate a new table that looks anthing like this?
>
>
>r# household inhabitants   house# ages
>1  Smiths    Robert, Bobby 27     42,4
>2  Barnes    Mary, Margy   74     32,2
>etc.
>
>
>Would it make a difference if the starting out table looked like this?
>
>
>r# household Parent house# ages
>1  Smiths    Robert 27     42
>2  Smiths    Bobby  27     4 && child of Robert
>3  Barnes    Mary   74     32
>4  Barnes    Margy  74     2 && child of Mary
>etc.
>
>

In fact, what you really need is a unique identifier for each family so that you're not dependent on the record's position in the table. What happens with your current structure when someone has a new baby?

The best way to do this is with two tables:
HOUSEHOLDS.DBF
iID   Name     House#
1     Smith    27
2     Barnes   74

PEOPLE.DBF
iID   iHousehold   FirstName  Age
1     1            Robert     42
2     1            Bobby      4
3     2            Mary       32
4     2            Margy      2
I'd also store a birthdate rather than an age.

To get the data you want, you'll need XBase code to loop through and consolidate. Why do you want the data in that format?

Tamar
Previous
Reply
Map
View

Click here to load this message in the networking platform