Question: I have an dynamic array of id which is passed by frontend. I need to fetch data from mysql db where the tuples ids are match with the ids which i pass.

> 
> Example Id array: [6, 7, ...]
> 
> 
> 

The number of items can be vary according to different requests.

```
SELECT expense_type, expense_category FROM expense_type WHERE expense_category_id=id1 OR expense_category_id=id2;

```

id1, id2 are the ids which comes from the frontend. (6,7,...)

There can be multiple ids which comes from the frontend. 
could i please know is there a way to fetch data from one query in such situation.
Or else do i have to write multiple queries to execute?

Answer: 
You need to make query by using that multiple ids's array.

something like below

```
query = 'SELECT expense_type, expense_category FROM expense_type WHERE expense_category_id IN (`;
forEach(ids as id) {
 query += id + ','
}

```

run query..
you can easily use an IN.
also try to use Join. so the accuracy of the query will get increase. 

```
SELECT expense_type, expense_category
FROM expense_type
WHERE expense_category_id IN ('id1', 'id2');

```