I have two tables as shown below:
Tablea

4c4fedf7 OMoy3Hoa
4c4fedf7 yiWDGB4D
broe4AMb A9rLRawV
broe4AMb mi9rLmZW
nhrtK9ce yEsBoYLj
rEEtK9gt A9rLRawV
rEEtK9gt mi9rLmZW
rEEtK9Hh A9rLRawV
rEEtK9Hh msBWz8CQ
Tableb

mr23wsSW formb 4c4fedf7
OBqSU9pm forma broe4AMb
UvYOMvLe formc broe4AMb
Bhc5yfr4 forma nhrtK9ce
R9vZJ5Kd formb nhrtK9ce
Bhc5y629 forma rEEtK9gt
Bhc5y488 forma rEEtK9Hh
Bhc5y489 formb rEEtK9Hh
In the table I have prodidand tagid. Its a composite primary key. prodidacts as a foreign key, pointing to a table. In tableb I have prod, formand link. prodidtable points to linktable b. I want if I give the tagidtables as inputs of type array, for example A9rLRawV,mi9rLmZW, I want the result to be as follows:
OBqSU9pm
UvYOMvLe
Bhc5y629
This is because I want prod, which has both A9rLRawVand mi9rLmZWin it the corresponding entry (prodid) in the table.
I have a query like:
SELECT b.prod AS links
FROM tablea a
INNER JOIN tableb b ON a.prodid = b.link
WHERE a.tagid IN ('A9rLRawV','mi9rLmZW')
GROUP BY b.prod
But it returns a result, for example:
OBqSU9pm
Bhc5y629
Bhc5y488
How can i fix this? I am using PHP + MySQL.