How to filter entries by tags array using ['or'] and by category not using or This works for filtering by tag array 

{% set relatedToParam = ['or'] %}

{% for id in selectedTagIds %}
    {% set relatedToParam = relatedToParam|merge([{
        targetElement: id
    }]) %}
{% endfor %}

{% set entries = craft.entries.relatedTo(relatedToParam) %}


But how can we add another relatedTo param for category so the results only show the selected tag entries from a category?

For example to achieve this:

...WHERE categoryid = 'myid' AND (tag1 LIKE 'green' OR tag2 LIKE 'red' OR tag3 LIKE 'yellow' etc)
The relatedTo function accepts multiple different formats. If you want to search for Elements that are related to a list of categories and a list of tags you can do that like this

relatedTo([
    'and',
    ['element' =&gt; [1, 2, 3]],
    ['element' =&gt; [4, 5, 6]]
]);


This will return you all Elements that are related to the first array and related to the second array. So you goal should be to create an array of category IDs and Tag IDs and pass them together in the relatedTo

To get Elements that are related to all elements of one array and a single one from another array do the following

relatedTo([
    'and',
    ['element' =&gt; [1, 2, 3]],
    ['element' =&gt; ['and', 4, 5, 6]]
]);