I have two tables like 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 tablea, I have prodid
and tagid
. Its a composite primary key. prodid
acts as a foreign key, pointing to tableb. In tableb, I have prod
, form
, and link
. prodid
of tablea points to link
of tableb. What I want is, if I give tagid
of tablea as inputs like array, like, A9rLRawV,mi9rLmZW
, I want output as;
OBqSU9pm
UvYOMvLe
Bhc5y629
This is because, I want prod, which has both A9rLRawV
and mi9rLmZW
in it's corresponding entry (prodid) in tablea.
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 result like;
OBqSU9pm
Bhc5y629
Bhc5y488
How can I fix this? I use PHP + MySQL.