MySQL 1000 OR statements (good idea?)

I am creating a Twitter application that captures all users and gets their specific identifier. Ex: 1223455

I also have a huge database full of lines that contain a specific Twitter identifier ... See examples in lines ...

|1| 122345   |
|2| 2232144  |
|3| 99653222 |
|4| 123232   |
|5| 2321323  |
|6| 3121322  |

The problem is that we all know that Twitter has more and more followers (1000), and I was wondering if this is a good MySQL query to run potentially up to 20 times in a single script run ..

SELECT * FROM table WHERE twitterID='132323' OR twitterId='23123' OR twitterId='23123' OR twitterId='23123' OR twitterId='23123' OR twitterId='23123' OR twitterId='23123' OR twitterId='23123

And further, further and further ... In one request there can potentially be more than 1000 OR operators (and a similar request can be called 20 times)

This doesn't seem like a very good programming practice, but I haven't heard of another way ... ??

+5
source share
3

in:

Select * from table where twitterid in (123,456,789,...)
+4

. MySQL OR.

JOIN -

WHERE twitterId IN (
      select * 
        from followers
       where followee = whatever
)
+4

Try the following:

SELECT * 
FROM table t1
WHERE twitterID 
      IN (select twitterID 
            from twitterIDsTable t2
           where t1.twitterID = t2.twitterID)--for performance
0
source

All Articles