On Apr 29, 2020, at 2:21 PM, Paul Dennis via 4D_Tech <[email protected]> 
wrote:
> 
> I have a collection created from arrays via mysql. This contains duplicated
> elements. I'm trying to do the equivalent of distinct values but the
> collection.distinct command does not do the distinction on a single
> attribute. 

I forgot to show what I’d do. Querying every distinct ID is likely to be slow 
if there are many rows. This could be simplified a bit.


ARRAY TO 
COLLECTION($companycol;$CompanyUUID;"UUID";$alContactMySqlID;"MySQLUserID";$asName;"Name";$asAddress;"AddressLine1";$asCity;"Town";$asPostcode;"PostCode”)

// MySQLItemID is not in the ARRAY TO COLLECTION?

// Sort the collection
$companycol:=$companycol.orderBy(“MySQLItemID”)

$uniqueCol:=New collection
$lastID:=-1
For each ($element;$companycol)
 If ($lastID#$element.MySQLItemID)
   $lastID:=$element.MySQLItemID
   $uniqueCol.push($element)
 End if
End for each



Jim Crate

**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to