Dohko


Hi

I need to know how to update a table in FoxPro.

My table has 1 column with numbers and 1 column for frequencies that is blank

SELECT State, COUNT(*) as Freq;
FROM sample;
GROUP BY State;
INTO CURSOR Counter

After this I do browse and see a column with the information I need

But when I would like to update that to the Frequencies column.

So I will be able to access the data in that column.

Thanks




Re: Updating Tables

Dohko


Can I store this data into an array




Re: Updating Tables

hangover

If I understand your query correctly, the following should do the trick (assuming sample is the table that you want to update)

UPDATE sample SET freq = counter.freq WHERE state = counter.state

Dom







Re: Updating Tables

Dohko

Ok, but How can i store that into an Array

I would like for example to ahve that column stored into

For n=1 to 51

Array(3,n)

endfor

Where n=entry.

Thanks





Re: Updating Tables

Naomi Nosonovsky

I'm sorry, Dohko, but why you're starting so many threads with the same question I already answered it in your other thread with UPDATE syntax for VFP9 and REPLACE syntax for VFP8.

If you need to store the information into arrays, you may directly select into array, since SELECT-SQL allows it in VFP.

E.g.

Code Snippet
select State, count(State) as Freq from MyTable group by 1 into array States





Re: Updating Tables

hangover

I'm not sure what you are asking here.

If you just want to create an array with each state and its associated frequency, do:

SELECT State, COUNT(*) as Freq;
FROM sample;
GROUP BY State;
INTO ARRAY aFrequency

If you have an existing array within which you want to store the frequency of each state in the corresponding column of the third row (assuming 'entry' = 'state'), follow this with:

FOR nState = 1 TO 51

nRow = ASCAN (aFrequency, nState, 1, -1, 1, 8)

Array (3, nState) = IIF (nRow = 0, 0, aFrequency (nRow, 2))

ENDFOR