Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7722413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:09:55+00:00 2026-06-01T04:09:55+00:00

Please consider the following tweets table: tweet_id user_id text —————————- 1 1 lorem ipsum

  • 0

Please consider the following “tweets” table:

tweet_id user_id text      
----------------------------
 1       1       lorem ipsum
 2       1       lorem ipsum
 3       2       pear
 4       1       dolor
 5       3       foo
 6       1       dolor
 7       1       dolor
 8       3       bar
 9       3       baz
10       4       happy
11       4       happy
12       2       apple
13       3       foo
14       4       happy

In reality, the table contains millions of tweets from about 80,000 users. Many of there users are spam accounts, but they are hard to identify by hand. As a rule of thumb, spam accounts post the same message at least 3 times. That’s why I want to fill the following tables, “duplicates” on the left and “duplicates_tweets” on the right:

duplicate_id user_id  text         cnt       duplicate_id  tweet_id
--------------------------------------       ----------------------
1            1        lorem ipsum  2         1              1
2            1        dolor        3         1              2
3            2        pear         1         2              4
4            2        apple        1         2              6
5            3        foo          2         2              7
6            3        bar          1         3              3
7            3        baz          1         4             12
8            4        happy        3         5              5
                                             5             13
                                             6              8
                                             7              9
                                             8             10
                                             8             11
                                             8             14

I can now very easily sort on cnt for instance, and see which users post the most duplicate messages. My question however, is how to go about this most efficiently. In other words: what query would be most efficient to fill these tables? And is it possible with just SQL or should I use PHP as an intermediary, for instance to take a tweet from the “tweets” database, scans for duplicates, fills the tables, and moves on to the next tweet? I’m afraid this would take ages to finish, so any help is greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T04:09:56+00:00Added an answer on June 1, 2026 at 4:09 am

    You can use the REPLACE function in MySQL to UPDATE or INSERT a new row based on the key:

    REPLACE duplicates
    SELECT user_id, text
    FROM (SELECT user_id, text, count(1) as count
    FROM tweets
    GROUP BY user_id, text
    HAVING count(1) > 2))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please consider the following string $text = Dat foo 13.45 and $600 bar {baz:70}
Please consider the following HTML: <td> Some Text <table>.....</table> </td> I need to manipulate
Please consider the following simple use case: public class Foo { public virtual int
Please consider the following code, struct foo { foo() { std::cout << Constructing! <<
Please consider the following table (created using a corresponding entity) request ------- id requestor
please consider the following code: template <typename T> struct foo { template <typename S>
Please consider the following scripts. Create Table: IF OBJECT_ID('Colortable') IS NOT NULL DROP TABLE
Please consider following schema CREATE table articles ( id Int UNSIGNED NOT NULL AUTO_INCREMENT,
Please consider following sample table structure: +-------------------------------+--------------+------+-----+---------+-------+ | Field | Type | Null |
Please Consider the following table : As you can see the Name column has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.