• RezaY

    (@mohammad983)


    on wp-usermeta I have some mobile value which duplicates.

    user id     metakey     meta value
    1            mobile        001912
    1            mobile        001912

    I want to write a SQL command to select and see a list from all users who have a duplicate number(with username).

Viewing 1 replies (of 1 total)
  • Hi, @mohammad983!

    Try this: I used the fields and table name stated above. Feel free to change them if needed.

    SELECT 
        user_id,    COUNT(user_id),
        metakey,    COUNT(metakey),
        meta_value, COUNT(meta_value)
    FROM
        wp-usermeta
    GROUP BY 
        user_id, 
        metakey, 
        meta_value
    HAVING  
        COUNT(user_id) > 1
        AND COUNT(metakey) > 1
        AND COUNT(meta_value) > 1;

    Hope this helps.

Viewing 1 replies (of 1 total)

The topic ‘search duplicate value on database’ is closed to new replies.