Mysqli: How to update by reading and looping through all the rows?
===

The following is an example structure:

    table `pligg`
    #id   #alpha     #num
    1       a        null
    2       b        null
    3       c        null
    4       a        null
    5       d        null
    6       b        null
    7       a        null
    8       e        null

i'd like to update the databse like this after a single mysqli query:

    table `pligg`
    #id   #alpha     #num
    1       a        1
    2       b        1
    3       c        1
    4       a        2
    5       d        1
    6       b        2
    7       a        3
    8       e        1

What i'm trying to do is to update the column `num` with the number of duplicate.
I tried this query, but in vain

    mysqli_query($mysqli, "UPDATE pligg SET 'num' = COUNT(DISTINCT alpha) WHERE 'id'<id") or die('</br>mySqli Error "</br>');