Reputation: 65
I am using PHP and MySQL, to get articles from 5 categories (id
: 1,2,3,4,5), I use this MySQL query:
select * from `articles` where `category` in(1,2,3,4,5)
It's ok with 5 categories, but how about 1,000 categories ? Can you give me some idea to solve this problem, thank you very much.
Note: the problem I want to tell is not non-working query, it is very slow to process, are there some ways to speed it up ?
Upvotes: 0
Views: 75
Reputation: 36110
Assuming you want to get all articles
for category
s starting from 1
, upto 1000
, you can use between:
select * from articles where category between 1 and 1000
Upvotes: 2