Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find person with longest name
Message
 
To
21/03/2018 12:59:42
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01658805
Message ID:
01658986
Views:
70
>>>>>But I can't figure out what count(ID) is doing, how to return the number of rows per ID, or how to limit my results
>>>>>to the rows that have the longest names?
>>>
>>>Use a shortened copy of the field cast into a char(200) or varchar as the group by and then join the result with the original. Can't remember a better workaround. Assume that all the names you have are such that if characters beyond 200 are different it doesn't mean it's a different person.
>>
>>Sometimes, the first 200 characters won't be enough to differentiate a newly updated memo from one recently edited. This solution seems to work, although since I had never used scan, I am sure I did it correctly? And if there is a way to do this with SQL, I would be very happy to know of it.
>>
>>
>>alter table toTable add column note1 memo 
>>&& make sure this field does not already exist, using a procedure for this purpose.
>>USE fromTable IN 0  
>>SELECT fromTable
>>INDEX on thisID UNIQUE TO indexID  && the key field
>>SELECT fromTable &&  the memo field is in this table
>>SCAN
>>	findThisID = thisID
>>	SELECT toTable  && insert the memo field in this table
>>	IF SEEK(findThisID)
>>		REPLACE note1 WITH fromTable.note1  
>>                && all other rows/fields are unique as a result of using a select distianct * ... into table toTable
>>                && but the memo field is missing.  So, find the key field and its memo in the fromTable
>>                && then insert the memo into the toTable.
>>	endif
>>ENDSCAN
>>
>
>You could do
>
>replace note1 with fromTable.note1 for seek(thisId, "fromTable")
>
>or some kind of update statement, which I'm not sure I can write correctly from the top of my head, something like
>
>update toTable set note1=fromTable.note1 from fromTable where toTable.thisId = fromTable.thisId
>
>(probably won't work but that's what I'd start with).

Your suggestion helped me streamline my thinking. This seems to work re doing an update via a procedure.
do setField3 with "updateTabl", "key_col", "fromTable", "update_Col"
PROCEDURE setField3 with toTable, keyField1,fromTable2, changeField
PARAMETERS               toTable, keyfield1,fromTable2, changeField
	SELECT &toTable
	REPLACE ALL &changeField WITH ""

	&& to table and set field
	h=toTable
	f=keyField1
	where1 = h + "." + f
	
	h=fromTable2
	f=keyField1
	where2 = h + "." + f

	h=toTable
	f=changeField
	setKey = h + "." + f
	
	h=fromTable2
	f=changeField
	setKey2 = h + "." + f

	*? &h

	Update  &toTable    From    &&fromTable2			;
	Where 	&where1 	=      &&where2 			;
	Set 	&setKey 	  =   &&setKey2

	*USE &toTable
	*BROWSE WIDTH 10 FONT "courier", 24 TITLE " after the update in procedure"
	*wait
ENDPROC
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform